Hi, Congratulations for the launch of Dancer2 on CPAN. I am trying to use it, but I couldn't find on POD docs the answer to a problem I found, regarding the WRAPPER directive on TT templates. I need to use different wrappers for different templates, and Template-toolkit allows using a directive like: [% WRAPPER wrapper1.tt %] ... [% END %] It also allows defining some variables to be used in the wrapper template using: [% title="The title"; WRAPPER wrapper1.tt %] ... [% END %] But I've found that if I use the directive WRAPPER in a Dancer2 application, it gives the error: Internal Server Error file error - parse error - D:\apps\web\MD\views\index.tt line 1: unexpected token (WRAPPER) [% WRAPPER wrapper.tt %] If I use the layout key in the config file, I can use the wrapper, but this way it is possible to use just a single wrapper and I can't associate different wrappers to different templates (but only if I define a layout in config file and add exceptions in the application code). Is it possible in some other way to define in templates the wrapper they use? And I also don't know if it is possible to define variables in templates and pass them to be displayed in the wrapper. Is it possible to do this, or I will need to define those vars in the code? I have also tried to do the following in the config: #layout: "main" template: "template_toolkit" engines: template_toolkit: WRAPPER: layouts/wrapper ENCODING: 'utf8' start_tag: '[%' end_tag: '%]' But the content of the wrapper was not displayed at all. Am I missing something? Thanks. --Octavian
2013/3/10 Octavian Rasnita <orasnita@gmail.com>:
I need to use different wrappers for different templates, and Template-toolkit allows using a directive like:
I am not sure, is this the same problem, which bites me, but it does not hurt to try it out. Instead of your conf try this one (set spaces as YAML likes, they may lost or added here): template: "template_toolkit" engines: template: template_toolkit: WRAPPER: layouts/wrapper ENCODING: 'utf8' start_tag: '[%' end_tag: '%]' -- Wbr, Kõike hääd, Gunnar
Great! This way it works. And the WRAPPER directive doesn't give that error anymore. I just changed an app built by Dancer (1) with "dancer -a AppName" but the config file it created was missing the "template" key. Thanks. --Octavian ----- Original Message ----- From: "WK" <wanradt@gmail.com> To: "Perl Dancer users mailing list" <dancer-users@dancer.pm> Sent: Sunday, March 10, 2013 8:15 PM Subject: Re: [dancer-users] Using TT's WRAPPER directive
2013/3/10 Octavian Rasnita <orasnita@gmail.com>:
I need to use different wrappers for different templates, and Template-toolkit allows using a directive like:
I am not sure, is this the same problem, which bites me, but it does not hurt to try it out. Instead of your conf try this one (set spaces as YAML likes, they may lost or added here):
template: "template_toolkit"
engines: template: template_toolkit: WRAPPER: layouts/wrapper ENCODING: 'utf8' start_tag: '[%' end_tag: '%]'
-- Wbr, Kõike hääd,
Gunnar _______________________________________________ dancer-users mailing list dancer-users@dancer.pm http://lists.preshweb.co.uk/mailman/listinfo/dancer-users
participants (2)
-
Octavian Rasnita -
WK