Hi - Just getting started with Dancer, so this might be an obvious question. I would like to be able to put per-route information into the layout template (for instance, current-page flagging in a navigation box, or setting the page title). Since it appears the only variable that is settable in the layout template is "content", my guess is that to do what I want I would need to shift all of that stuff into the per-page templates (or into common templates that are included into the per-page templates). Am I reading this correctly? Thanks, --bob
I'm actually at the movies now but I wanted to take a sec to say any variable works in the layout template :) On Mar 27, 2010 10:49 PM, "Robert Olson" <bob@rdolson.org> wrote: Hi - Just getting started with Dancer, so this might be an obvious question. I would like to be able to put per-route information into the layout template (for instance, current-page flagging in a navigation box, or setting the page title). Since it appears the only variable that is settable in the layout template is "content", my guess is that to do what I want I would need to shift all of that stuff into the per-page templates (or into common templates that are included into the per-page templates). Am I reading this correctly? Thanks, --bob _______________________________________________ Dancer-users mailing list Dancer-users@perldancer.org http://www.backup-manager.org/cgi-bin/listinfo/dancer-users
Doh, I cleverly read the code but missed the first half of {%$tokens, content => $content}) Thanks much. --bob On Mar 27, 2010, at 3:26 PM, sawyer x wrote:
I'm actually at the movies now but I wanted to take a sec to say any variable works in the layout template :)
On Mar 27, 2010 10:49 PM, "Robert Olson" <bob@rdolson.org> wrote:
Hi -
Just getting started with Dancer, so this might be an obvious question.
I would like to be able to put per-route information into the layout template (for instance, current-page flagging in a navigation box, or setting the page title).
Since it appears the only variable that is settable in the layout template is "content", my guess is that to do what I want I would need to shift all of that stuff into the per-page templates (or into common templates that are included into the per-page templates).
Am I reading this correctly?
Thanks, --bob _______________________________________________ Dancer-users mailing list Dancer-users@perldancer.org http://www.backup-manager.org/cgi-bin/listinfo/dancer-users
no problem. The fact you weren't sure might mean the docs missed expressing it. Would you be interesting in helping form some change to the docs so others won't get confused? On Mar 27, 2010 11:32 PM, "Robert Olson" <bob@rdolson.org> wrote: Doh, I cleverly read the code but missed the first half of {%$tokens, content => $content}) Thanks much. --bob On Mar 27, 2010, at 3:26 PM, sawyer x wrote: > I'm actually at the movies now but I wanted to tak...
Sure - how about something like this in the layout section on the main Dancer page: A layout is a special view, located in the 'layouts' directory (inside the views directory) which must have a token named `content'. That token marks the place where to render the action view. This lets you define a global layout for your actions. Any tokens that you defined when you called the 'template' keyword are available in the layouts, as well as the standard session, request, and params tokens. This allows you to insert per-page content into the HTML boilerplate, such as page titles, current-page tags for navigation, etc. Perhaps the example should then look like <html> <head> <title>[% page_title %]</title> </head> <body> <div id="header"> ... </div> <div id="content"> <% content %> </div> </body> </html> This layout can be used like the following: use Dancer; use Template; layout 'main'; get '/' => sub { template 'index' => { page_title => "Your website homepage", }; BTW I'm thoroughly enjoying a build of an app using Dancer. I'm getting it done hugely faster than the classic cgi-per-page way I've been doing for too many years. --bob On Mar 27, 2010, at 6:16 PM, sawyer x wrote:
no problem. The fact you weren't sure might mean the docs missed expressing it. Would you be interesting in helping form some change to the docs so others won't get confused?
On Mar 27, 2010 11:32 PM, "Robert Olson" <bob@rdolson.org> wrote:
Doh, I cleverly read the code but missed the first half of
{%$tokens, content => $content})
Thanks much.
--bob On Mar 27, 2010, at 3:26 PM, sawyer x wrote: > I'm actually at the movies now but I wanted to tak...
On 03/28/2010 12:29 AM, Robert Olson wrote:
Sure - how about something like this in the layout section on the main Dancer page:
Hi Robert, thank you for the doc, it's commited :) -- Franck Cuny - http://lumberjaph.net GPG keyid: 0x1A6B0C28 - http://pgp.mit.edu/ "no rain but thunder, and the sound of giants ..."
Sorry, the internet went down for the entire city and it became uncomfortable to do it all by cell. Thanks Robert for the docs! We really appreciate it. :) On Sun, Mar 28, 2010 at 11:30 AM, franck cuny <franck@lumberjaph.net> wrote:
On 03/28/2010 12:29 AM, Robert Olson wrote:
Sure - how about something like this in the layout section on the main Dancer page:
Hi Robert, thank you for the doc, it's commited :)
-- Franck Cuny - http://lumberjaph.net
GPG keyid: 0x1A6B0C28 - http://pgp.mit.edu/
"no rain but thunder, and the sound of giants ..."
_______________________________________________ Dancer-users mailing list Dancer-users@perldancer.org http://www.backup-manager.org/cgi-bin/listinfo/dancer-users
On Sun, Mar 28, 2010 at 2:29 AM, Robert Olson <bob@rdolson.org> wrote:
Sure - how about something like this in the layout section on the main Dancer page:
Hi Robert! I forgot to mention your patch went in Dancer 1.172 when it was released! You can view the "CHANGES" file. Sawyer.
participants (3)
-
franck cuny -
Robert Olson -
sawyer x