[dancer-users] Using TT's WRAPPER directive

Octavian Rasnita orasnita at gmail.com
Sun Mar 10 14:52:15 GMT 2013


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



More information about the dancer-users mailing list