I just found Template::Plugin::EnvHash<https://metacpan.org/pod/Template::Plugin::EnvHash>which enables to access environment variables from within any template. It works, so that's possibly solved. The worrying bit is that the author hasn't uploaded anything to CPAN since 2007.
Now I'm thinking I could maybe save the file paths in a YAML configuration file, and load them from within the template. That could be easier to maintain. Any alternative practices? --- I check email a couple times daily; to reach me sooner, you can send me a text message via this page: https://awayfind.com/mascip On 30 October 2013 16:38, Tiago Quintela <[email protected]> wrote: > Hi, > > use hook before to add config->{environment}->{static_files} to the view. > > set your config in config->{environment} $APP_DIR/environments/* > > hook 'before_template' => sub { > my $request = shift; > $resquest->{static_files} = config->{environment}->{static_files}; > # or... > $resquest->{config} = config; > }; > > regards > > > > On 30 October 2013 16:25, Pierre M <[email protected]> wrote: > >> Hi everyone, >> I'm deploying my first Dancer2 app, and I want to use different CSS+JS >> files in development and production. What are good ways to do this? >> (simple, maintainable) >> >> The solution I've imagined so far is to have two separate list of files, >> and manually include one or the other into my layout with >> Template::Toolkit's <% INCLUDE filename %>. There must be a better way. >> >> Unfortunately, I haven't found how to access environment variables inside >> the layout file. >> Pierre >> >> >> --- >> I check email a couple times daily; to reach me sooner, you can send me a >> text message via this page: https://awayfind.com/mascip >> >> _______________________________________________ >> dancer-users mailing list >> [email protected] >> http://lists.preshweb.co.uk/mailman/listinfo/dancer-users >> >> > > > -- > Tiago Quintela > > _______________________________________________ > dancer-users mailing list > [email protected] > http://lists.preshweb.co.uk/mailman/listinfo/dancer-users > >
_______________________________________________ dancer-users mailing list [email protected] http://lists.preshweb.co.uk/mailman/listinfo/dancer-users
