"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