what does everyone use to indent/beautify their TMPL files?
hiya Everyone, ive been thinking (for a while) about a way to standardize the way we format/indent *.tmpl files in koha because... some of the *.tmpl files i create look awful, and they are just too complex for me to work out a consistant way of formatting them. ive been playing a little with 'tidy' recently (http://tidy.sourceforge.net/) and ive got 'tidy' to parse and indent a tmpl file without too much moaning, using a config .rc file like this... $ cat .tidyrc new-blocklevel-tags: tmpl_loop tmpl_if tmpl_else tmpl_unless new-inline-tags: tmpl_var tmpl_include indent: auto indent-spaces: 1 vertical-space: n wrap: 0 then, run tidy like so... $ tidy -c .tidyrc test.tmpl -- so, the question is...... - what tools does everyone use for their own *.tmpl indenting/formatting/beautifying? - are there better ones than 'tidy'? - is it a good idea for us to find a tool that formats our tmpl files in a standard way? any ideas folks? cheers, Mason. -- Mason James Katipo Communications www.katipo.co.nz +64 4 934 1285
Hey Mason, Thanks for posting this. I've not had a chance to play with tidy, but I'll give it a shot next time I write something. I wonder if you'd be willing to add some information about how to use it to our Koha Coding Guidelines draft: http://wiki.koha.org/doku.php?id=en:development:codingguidelines Cheers, -- Joshua Ferraro SUPPORT FOR OPEN-SOURCE SOFTWARE President, Technology migration, training, maintenance, support LibLime Featuring Koha Open-Source ILS jmf@liblime.com |Full Demos at http://liblime.com/koha |2(888)KohaILS On Thu, Nov 09, 2006 at 02:04:41PM +1300, Mason James wrote:
hiya Everyone,
ive been thinking (for a while) about a way to standardize the way we format/indent *.tmpl files in koha
because... some of the *.tmpl files i create look awful, and they are just too complex for me to work out a consistant way of formatting them.
ive been playing a little with 'tidy' recently (http://tidy.sourceforge.net/) and ive got 'tidy' to parse and indent a tmpl file without too much moaning, using a config .rc file like this...
$ cat .tidyrc new-blocklevel-tags: tmpl_loop tmpl_if tmpl_else tmpl_unless new-inline-tags: tmpl_var tmpl_include indent: auto indent-spaces: 1 vertical-space: n wrap: 0
then, run tidy like so...
$ tidy -c .tidyrc test.tmpl
--
so, the question is......
- what tools does everyone use for their own *.tmpl indenting/formatting/beautifying? - are there better ones than 'tidy'? - is it a good idea for us to find a tool that formats our tmpl files in a standard way?
any ideas folks?
cheers, Mason.
-- Mason James Katipo Communications www.katipo.co.nz +64 4 934 1285
I've been playing with tidy to clean up my template files, but I find that in files that are missing some tags like <html> and <head> (because they are included in a seperate file), tidy creates them even though I don't want it to. Have you experienced that? Kyle On 11/8/06, Mason James <mason@katipo.co.nz> wrote:
hiya Everyone,
ive been thinking (for a while) about a way to standardize the way we format/indent *.tmpl files in koha
because... some of the *.tmpl files i create look awful, and they are just too complex for me to work out a consistant way of formatting them.
ive been playing a little with 'tidy' recently (http://tidy.sourceforge.net/) and ive got 'tidy' to parse and indent a tmpl file without too much moaning, using a config .rc file like this...
$ cat .tidyrc new-blocklevel-tags: tmpl_loop tmpl_if tmpl_else tmpl_unless new-inline-tags: tmpl_var tmpl_include indent: auto indent-spaces: 1 vertical-space: n wrap: 0
then, run tidy like so...
$ tidy -c .tidyrc test.tmpl
--
so, the question is......
- what tools does everyone use for their own *.tmpl indenting/formatting/beautifying? - are there better ones than 'tidy'? - is it a good idea for us to find a tool that formats our tmpl files in a standard way?
any ideas folks?
cheers, Mason.
-- Mason James Katipo Communications www.katipo.co.nz +64 4 934 1285
_______________________________________________ Koha-devel mailing list Koha-devel@nongnu.org http://lists.nongnu.org/mailman/listinfo/koha-devel
-- IT Tech Crawford County Federated Library System
"Mason James" <mason@katipo.co.nz> writes:
hiya Everyone,
Hi,
ive been thinking (for a while) about a way to standardize the way we format/indent *.tmpl files in koha
because... some of the *.tmpl files i create look awful, and they are just too complex for me to work out a consistant way of formatting them.
During April/May 2006, I've made some "code refactoring" on templates, for example aqbudget.tmpl [1]. The strategy was a two levels indent: an indent for HTML, another indent for template blocks. <!-- TMPL_IF name="else" --> <h1>Budget admin</h1> <table> <tr> <th>Book fund</th> <th>Branch</th> <th>Start date</th> <th>End date</th> <th>Budget amount</th> <th>Actions</th> </tr> <form action="/cgi-bin/koha/admin/aqbudget.pl" method="post"> <tr class="filter"> <td> <select name="filter_bookfundid"> <option value="">----</option> <!-- TMPL_LOOP name="filter_bookfundids" --> <!-- TMPL_IF NAME="selected" --> <option value="<!-- TMPL_VAR name="bookfundid" -->" selected="selected"><!-- TMPL_VAR name="bookfundid" --></option> <!-- TMPL_ELSE --> <option value="<!-- TMPL_VAR name="bookfundid" -->"><!-- TMPL_VAR name="bookfundid" --></option> <!-- /TMPL_IF --> <!-- /TMPL_LOOP --> [...] If I extract the template blocks, it becomes: <!-- TMPL_IF name="else" --> <!-- TMPL_LOOP name="filter_bookfundids" --> <!-- TMPL_IF NAME="selected" --> <!-- TMPL_ELSE --> <!-- /TMPL_IF --> <!-- /TMPL_LOOP --> [...] Using a double indentation system, at the end of the template you know if you have closed all blocks. Having a template_tidy tool would have been very useful for me :-) [1] koha-tmpl/intranet-tmpl/prog/en/admin/aqbudget.tmpl Cheers, -- Pierrick LE GALL
Mason James a écrit :
hiya Everyone,
Hi, even if all black have beaten frenchies badly twice, I'm still with you onboard :-D
- what tools does everyone use for their own *.tmpl indenting/formatting/beautifying?
I use : my eyes & my hand, with the tab key. I have changed the behaviour recently and now indent only with spaces, not tab, as I agree there are awful consequences if your tab length is not the same as mine...
- are there better ones than 'tidy'? - is it a good idea for us to find a tool that formats our tmpl files in a standard way?
I'm OK to use a standard tool if we can find one. However, I did not investigate to find any, so if anyone has a suggestion or everydoby is happy with this tidy setup, i'll give him a try. cheers. -- Paul POULAIN et Henri Damien LAURENT Consultants indépendants en logiciels libres et bibliothéconomie (http://www.koha-fr.org) Tel : 04 91 31 45 19
participants (5)
-
Joshua Ferraro -
Kyle Hall -
Mason James -
Paul POULAIN -
Pierrick LE GALL