Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
How can I make my forms and page sources pretty?
I have excessively worked on several forms and pages. Now all my HTML/TXP tags source code is messy and hard to maintain. I would like to apply pretty indentation and tidy the code.
What is the suggested way to perform the code cleanup? How do others do this? Do you use an editor on your local computer or throw the code bits to something like HTMLTidy? I am curious what the common best practices are to have pretty template code in your Textpattern backend.
Yoko for Textpattern – A free blog theme • Minimum Theme – If all you want to do is write.
Note: I am currently not actively using Textpattern, so I am not in the forums very often
Offline
Re: How can I make my forms and page sources pretty?
Hi stephan
would upm-insert-tab be of help?
Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.
Offline
Re: How can I make my forms and page sources pretty?
A little, but the code is so messy now I would really prefer something a little more automated. And yes I would be willing to use external tools :-)
Yoko for Textpattern – A free blog theme • Minimum Theme – If all you want to do is write.
Note: I am currently not actively using Textpattern, so I am not in the forums very often
Offline
Re: How can I make my forms and page sources pretty?
If you are talking about the txp pages/forms themselves, just paste it into any text editor and manually tab or space out the indents then paste back into textpattern.
Offline
Re: How can I make my forms and page sources pretty?
Tanks Phil. Is there any less manual way? I stumbled across Tabifier and am quite happy with it (for now). But being lazy as I am I am also quite shocked to see that everyone else seems to be so much more diligent about their work that they actually format code manually.
Then again, maybe it is just me being more lazy than the real developers…
Yoko for Textpattern – A free blog theme • Minimum Theme – If all you want to do is write.
Note: I am currently not actively using Textpattern, so I am not in the forums very often
Offline
Re: How can I make my forms and page sources pretty?
Hi
There is an extention for firefox <it’s all texte> that let you open a web content into an external editor to modify it, and when you save on external editor the webpage is updated.
There also plugin that add code hilight inside textpattern itself like:
Cheers
Online
#7 2011-07-04 20:17:42
- uli
- Moderator
- From: Cologne
- Registered: 2006-08-15
- Posts: 4,315
Re: How can I make my forms and page sources pretty?
One of the little spots where I don’t like TXP too much is exactly the ugly code it produces: You can either keep your forms and pages indented for readability or your HTML. Not both. I’d be happy if a plugin fell from heaven.
Stephan, if you’re on a Mac and happen to have BBEdit: You could use Markup > Utilities > Optimize, and then Markup > Utilities > “Format …” which seems to leave pretty little reason for optimizing manually, though I didn’t try it too often: I indent my code by hand and use FF’s It’s All Text extension.
In bad weather I never leave home without wet_plugout, smd_where_used and adi_form_links
Offline
Re: How can I make my forms and page sources pretty?
@uli
Use googles mod_pagespeed apache module, specifically the collapse whitespace option, and you can have nice formatted forms and tidy HTML output. Works a treat for me.
Last edited by philwareham (2011-07-05 09:01:03)
Offline
Re: How can I make my forms and page sources pretty?
I know this doesn’t help your situation, but I prefer to manually indent two spaces for each level of indentation. I find that coding in a text editor preserves tabs which take up a ridiculous amount of space when copied into Textpattern. Two spaces is enough to see each level of indentation without taking up too much space.
Of course, this works best when working from scratch.
Offline
Re: How can I make my forms and page sources pretty?
Use googles mod_pagespeed apache module, specifically the collapse whitespace option, and you can have nice formatted forms and tidy HTML output. Works a treat for me.
Interesting, I’d not seen that before. It makes the output tidier (but only partially more readable), however I always wonder whether the supposed performance gain by optimizing page source is not eaten up by the fact that the module has to reformat each page on the fly?
You could also go the whole hog and use <txp:aks_header strip=‘1’ gzip=‘1’ /><!DOCTYPE html… along with caching, but the resulting code is completely unreadable.
What’s nice about cleaning output post-txp means you can have more verbose and readable txp forms and page templates. You can achieve fairly “good looking” source code from txp, but at the expense of making your txp forms less readable.
I prefer to manually indent two spaces for each level of indentation. I find that coding in a text editor preserves tabs which take up a ridiculous amount of space when copied into Textpattern.
If you work with cnk_versioning then you can have your cake and eat it. Firstly the code edit panes become a thing of the past. In addition many code editors allow you to indent with spaces rather than tabs, to convert between spaces and tabs, and to set the number of spaces the tab key should indent.
TXP Builders – finely-crafted code, design and txp
Online