Feeding options to Dancer::Template::HtmlTemplate
Hi all, I am migrating a vanilla CGI application that relies on HTML::Template to dancer, and so of course I will use the Dancer::Template::HtmlTemplate library for now. Where do I feed my usual HTML::Template options like loop_context_vars, global_vars, and so on to the plugin? The source code indicates that there is a %{$self->config} that is passed on to HTML::Template, but its not clear to me when to fill this out. I'm very much learning as I go, so I apologize if this covered somewhere in the documentation that I missed. Thanks! GJ
On Wed, 15 Feb 2012 19:46:36 +0000 GJ <gj@freeshell.org> wrote:
Hi all,
I am migrating a vanilla CGI application that relies on HTML::Template to dancer, and so of course I will use the Dancer::Template::HtmlTemplate library for now.
Where do I feed my usual HTML::Template options like loop_context_vars, global_vars, and so on to the plugin? The source code indicates that there is a %{$self->config} that is passed on to HTML::Template, but its not clear to me when to fill this out.
That should come from the template engine's config in config.yml - so you'd want something like: engines: HtmlTemplate: loop_context_vars: ... global_var: ... Whilst that's how it works for all the template engines, it should probably be documented better - I'll try to find a moment to update the docs to show an example. Cheers Dave P -- David Precious ("bigpresh") <davidp@preshweb.co.uk> http://www.preshweb.co.uk/ www.preshweb.co.uk/twitter www.preshweb.co.uk/linkedin www.preshweb.co.uk/facebook www.preshweb.co.uk/cpan www.preshweb.co.uk/github
On Thu, Feb 16, 2012 at 11:06:31AM +0000, David Precious wrote:
On Wed, 15 Feb 2012 19:46:36 +0000 GJ <gj@freeshell.org> wrote:
Hi all,
I am migrating a vanilla CGI application that relies on HTML::Template to dancer, and so of course I will use the Dancer::Template::HtmlTemplate library for now.
Where do I feed my usual HTML::Template options like loop_context_vars, global_vars, and so on to the plugin? The source code indicates that there is a %{$self->config} that is passed on to HTML::Template, but its not clear to me when to fill this out.
That should come from the template engine's config in config.yml - so you'd want something like:
engines: HtmlTemplate: loop_context_vars: ... global_var: ...
Whilst that's how it works for all the template engines, it should probably be documented better - I'll try to find a moment to update the docs to show an example.
Thanks for this information! Then for hypothetical savings, to turn off or on particular settings for a given route, I'd have to do something like this I suppose: config->{engines}->{HtmlTemplate}->{expensive_option} = 0 et cetera? Thanks, GJ
participants (2)
-
David Precious -
GJ