koha-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Koha-devel] what does everyone use to indent/beautify their TMPL fi


From: Pierrick LE GALL
Subject: Re: [Koha-devel] what does everyone use to indent/beautify their TMPL files?
Date: Thu, 09 Nov 2006 15:09:13 +0100
User-agent: Gnus/5.1007 (Gnus v5.10.7) Emacs/21.4 (gnu/linux)

"Mason James" <address@hidden> 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




reply via email to

[Prev in Thread] Current Thread [Next in Thread]