Clayton Scott wrote:
> On Fri, Mar 20, 2009 at 7:29 PM, Darren Chamberlain <[email protected]> 
> wrote:
>> It's a precedence issue.  This:
>>
>> [% SET cap = 'capitalised' | upper %]
>> [% cap %]
>>
>> Is, effectively, this:
>>
>> [% FILTER upper %][% SET cap = 'capitilized' %][% END %]
>> [% cap %]
>>
>> SET has higher precedence than other operators.  You should make SET
>> operations their own statement.
> 
> It's not causing me any problems but I thought it was interesting when I
> I added the SET operator to the statement. The docs imply that an
> assignment operation
> works exactly the same with or without a SET.
> 
> http://tt2.org/docs/manual/Directives.html#section_SET
> 
> Clayton

A similar problem of precedence is noted, but not explained, here:

http://tt2.org/docs/manual/Syntax.html#section_Capturing_Block_Output

... In other words, the following directive will always cause 'var' to 
be cleared.

      [% var = 'value' IF 0 %]

To achieve the expected behaviour, the directive should be written as:

      [% SET var = 'value' IF some_condition %]

_______________________________________________
templates mailing list
[email protected]
http://mail.template-toolkit.org/mailman/listinfo/templates

Reply via email to