[Dancer-users] defining a variable in a template that the layout can read

Brian E. Lozier brian at massassi.com
Thu Mar 10 16:52:33 CET 2011


I actually tried this but it doesn't seem to work.  I think it's
because the Dancer layout is processed separately from the template.
I think the SET variables only work in templates that are directly
included in the template you're processing now.  I'm looking for
something that is compatible with the way Dancer handles layouts.  I
could be doing it wrong.  I tried this:

In layout.tt I have <% title %>

In home.tt I have this <% SET title = 'Home' %>

And title in layout.tt remains unset.

Thank you,

On Thu, Mar 10, 2011 at 7:42 AM, Tobias <tobiash at gmail.com> wrote:
> Look at TT's Syntax
> document: http://template-toolkit.org/docs/manual/Syntax.html
> You can use "SET" to assign values inside a template, which can be reused
> later on.
> --Tobias
> On Thu, Mar 10, 2011 at 8:39 AM, Brian E. Lozier <brian at massassi.com> wrote:
>> I realized that the only user-visible strings that are in my dancer
>> perl code are the titles for pages.  It's because I do stuff like
>> this:
>> template 'foo.tt', { title => 'My Title' };
>> Is there a way to define title in foo.tt such that the layout template
>> can see it?
>> _______________________________________________
>> Dancer-users mailing list
>> Dancer-users at perldancer.org
>> http://www.backup-manager.org/cgi-bin/listinfo/dancer-users

More information about the Dancer-users mailing list