[Dancer-users] IF statement issues in template

J. Bobby Lopez jbl at jbldata.com
Thu Apr 21 17:22:19 CEST 2011


Problem solved, but not sure why.

It looks like I wasn't using 'template_toolkit' as my layout engine after
all.  As soon as I enabled that in my config.yml, the IF statement worked.

Now this is confusing, because I thought that doing a  'set template =>
'template_toolkit';' in the code itself before I pushed data to the template
would be enough.

Any ideas on why that didn't work as I expected?

-Bobby

On Thu, Apr 21, 2011 at 11:07 AM, J. Bobby Lopez <jbl at jbldata.com> wrote:

> You're right, sorry I used the wrong delimiters in my explanation, but in
> the code it's the correct brackets "<>" being used.  Still the same problem.
>
>
> On Thu, Apr 21, 2011 at 11:05 AM, Alberto Simoes <ambs at perl-hackers.net>wrote:
>
>>
>> By default, when using template toolkit, Dancer will preserve the
>> delimiters:
>>
>>
>>  <% IF blah %>
>>    show this
>>  <% END %>
>>
>> So, if you didn't configure anything about the delimiters, and just
>> switched from Simple to TT, this is what you should use.
>>
>> Cheers
>>
>>
>> On 21/04/2011 16:03, J. Bobby Lopez wrote:
>>
>>> Curious if anyone's run into this.. I have an IF statement in a
>>> template, like so:
>>>
>>> [% IF blah %]
>>>   show this
>>> [% END %]
>>>
>>>
>>> I'm using template::toolkit (not template::simple) like so:
>>>
>>> set template => 'template_toolkit';
>>> template 'index' =>
>>> {
>>>    form => $form,
>>>    var1 => $var1,
>>>    var2 => $var2,
>>>    var3 => $var3,
>>> };
>>>
>>>
>>> When I load it all up in the browser, the IF statement doesn't work (is
>>> ignored), and the "show this" is displayed, even though "blah" doesn't
>>> exit.
>>>
>>> What am I doing wrong?  Is it my lack of TT knowledge, or something I've
>>> done incorrectly in my Dancer config?
>>>
>>> Thanks,
>>> -Bobby
>>>
>>>
>>>
>>> _______________________________________________
>>> Dancer-users mailing list
>>> Dancer-users at perldancer.org
>>> http://www.backup-manager.org/cgi-bin/listinfo/dancer-users
>>>
>>
>> _______________________________________________
>> Dancer-users mailing list
>> Dancer-users at perldancer.org
>> http://www.backup-manager.org/cgi-bin/listinfo/dancer-users
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.backup-manager.org/pipermail/dancer-users/attachments/20110421/848ad08e/attachment.htm>


More information about the Dancer-users mailing list