On 07/02/11 14:22, Jiří Pavlovský wrote:
> Hi,
>
> I Have a block like below. It will produce the following output when
> included with the 'collapse' filter.:
>
> "- name1 , name2 , and name 3 en".
>
> I need to get rid of the space in front of comas, but cannot figure out
> a way to do it. I tried all possible combinations of TRIM and CHOMP
> options., Both globally and on tag levels to no avail.
> Any help would be appreciated.
>
>
> - [% FOREACH author IN COLUMN.list_authors %]
>
> [% IF loop.last %]
>
> [% IF COLUMN.number_of_authors == 2 %] and [% END %]
> [% IF COLUMN.number_of_authors> 2 %], and [% END %]
>
> [% author.get_name(LANGUAGE) %]
> [% ELSIF loop.first %]
>
> [% author.get_name(LANGUAGE) %]
>
> [% ELSE %]
> , [% author.get_name(LANGUAGE) %]
> [% END %]
>
> [% END # of authors loop%]
>
>
> _______________________________________________
> templates mailing list
> [email protected]
> http://mail.template-toolkit.org/mailman/listinfo/templates
The unwanted space is probably being introduced by the formatting
between your TT directives. For example, the spaces indicated in the
following extract will be converted to a single space when the output is
displayed in a browser:
[% ELSE %]
, [% author.get_name(LANGUAGE) %]
^^^^
[% END %]
There are a few ways to solve this. The messy way is to put all your
directives on one line so that no extra white space is introduced. A
better option is to use the PRE_CHOMP and POST_CHOMP options:
http://template-toolkit.org/docs/manual/Config.html#section_PRE_CHOMP_POST_CHOMP
You could experiment with individual chomping options by using the + or
- options in the tags. For example:
[% ELSE -%]
, [% author.get_name(LANGUAGE) %]
[%- END %]
Personally, I prefer to set the PRE_CHOMP configuration option to 1 and
the POST_CHOMP option to 0, and then explicitly disable chomping where
required by using the + option in the tag. For example:
<div class="comment [%+ loop.parity %]">
^
With PRE_CHOMP set to 1, the space between 'comment' and the start of
the TT tag would normally be removed. Adding the + option to the tag
prevents this from happening.
_______________________________________________
templates mailing list
[email protected]
http://mail.template-toolkit.org/mailman/listinfo/templates