Accessing config in the templates
Hi, I was sure the config hash is accessible in the templates, but I found that it is not. Then I read: "note that for convenience, the request, session, params and vars are automatically accessible in the view, named "request", "session", "params" and "vars" I think it could be useful if the config would be also accessible. Or is there a reason this would not be a good idea? --Octavian
Hi, I'm not sure if this is omitted for a reason or not, but I think you can reasonably simulate this by adding a hook (before_template_render or something like that - not got doc to hand) and just inserting the configuration data into the output data at that point. Cheers, Rik Sent from my phone. On 10 Mar 2013 15:46, "Octavian Rasnita" <orasnita@gmail.com> wrote:
Hi,
I was sure the config hash is accessible in the templates, but I found that it is not.
Then I read:
"note that for convenience, the request, session, params and vars are automatically accessible in the view, named "request", "session", "params" and "vars"
I think it could be useful if the config would be also accessible. Or is there a reason this would not be a good idea?
--Octavian
______________________________**_________________ dancer-users mailing list dancer-users@dancer.pm http://lists.preshweb.co.uk/**mailman/listinfo/dancer-users<http://lists.preshweb.co.uk/mailman/listinfo/dancer-users>
On Sun, Mar 10, 2013 at 12:01 PM, Rik Brown <rik@rikbrown.co.uk> wrote:
I think it could be useful if the config would be also accessible. Or is there a reason this would not be a good idea?
I wouldn't want things like database password to be automatically available. Then a template bug could cause a huge security hole. I think if you want to make config data available in templates, it's be to do that yourself, explicitly and limit it only to keys you need. David -- David Golden <xdg@xdg.me> Take back your inbox! → http://www.bunchmail.com/ Twitter/IRC: @xdg
On Sun, Mar 10, 2013 at 11:44 AM, David Golden <xdg@xdg.me> wrote:
On Sun, Mar 10, 2013 at 12:01 PM, Rik Brown <rik@rikbrown.co.uk> wrote:
I think it could be useful if the config would be also accessible. Or is there a reason this would not be a good idea?
I wouldn't want things like database password to be automatically available. Then a template bug could cause a huge security hole.
I think if you want to make config data available in templates, it's be to do that yourself, explicitly and limit it only to keys you need.
Be it good or bad, you can access config with 'settings' keyword in templates. I'm not sure what but some of the variables are removed/hidden in error pages. I'm not sure about them in other areas. see 'Template Tokens' in https://metacpan.org/module/Dancer::Template::Abstract
From: Lee Carmichael On Sun, Mar 10, 2013 at 11:44 AM, David Golden <xdg@xdg.me> wrote: On Sun, Mar 10, 2013 at 12:01 PM, Rik Brown <rik@rikbrown.co.uk> wrote: >> I think it could be useful if the config would be also accessible. Or is >> there a reason this would not be a good idea? I wouldn't want things like database password to be automatically available. Then a template bug could cause a huge security hole. I think if you want to make config data available in templates, it's be to do that yourself, explicitly and limit it only to keys you need. Be it good or bad, you can access config with 'settings' keyword in templates. I'm not sure what but some of the variables are removed/hidden in error pages. I'm not sure about them in other areas. see 'Template Tokens' in https://metacpan.org/module/Dancer::Template::Abstract I checked but it doesn't seem to be that module for Dancer2. Octavian
participants (4)
-
David Golden -
Lee Carmichael -
Octavian Rasnita -
Rik Brown