[Dancer-users] Accessing template variables inside Wrapper (layout)

Deepak Gulati deepak.gulati at gmail.com
Fri Dec 31 09:54:29 CET 2010


Thanks.

>> Template toolkit allows me to set variables inside a template and then
>> access them from the wrapper:
>> http://www.template-toolkit.org/docs/manual/Config.html#section_WRAPPER
>
> Yes, these variables are called META variables. If you're on the IRC
> channel, you've probably heard me mention them quite a bit recently.
>
For some reasons TT2 documentation calls out META separately from the
behavior of template variables being accessible via the wrapper.

http://www.template-toolkit.org/docs/manual/Directives.html#section_WRAPPER
"One side-effect of the "inside-out" processing of the WRAPPER
configuration item (and also the WRAPPER directive) is that any
variables set in the template being wrapped will be visible to the
template doing the wrapping, but not the other way around."
...
snip
....
"It achieves the same effect as defining META items which are then
accessed via the template variable (which you are still free to use
within WRAPPER templates), but gives you more flexibility in the type
and complexity of data that you can define."

That said, this solution works for me in both cases:
1. Using META to declare a variable in the template and accessing it
via template. inside wrapper.
2. Accessing a (non META) variable declared in the template directly
inside the wrapper.

So thanks again!

I am nitpicking here, but probably we should warn/error out if both
layout: and WRAPPER: configuration options are both active together in
config.yml


More information about the Dancer-users mailing list