Opened a ticket with this including a test case. https://github.com/PerlDancer/Dancer2/issues/1059 It would be nice if someone could review it. Gabor On Thu, Nov 12, 2015 at 5:00 PM, Gabor Szabo <gabor@szabgab.com> wrote:
On Tue, Nov 10, 2015 at 3:18 PM, Russell Jenkins < russell.jenkins@strategicdata.com.au> wrote:
On 10/11/2015 6:06 pm, Gabor Szabo wrote:
Is there a solution? If currently not,would it be possible to allow views to be either a string or an array ref to strings?
Allowing views to be an arrayref of strings is likely to cause issues with other template engines.
TT2 allows you to supply coderefs as part of its INCLUDE_PATH configuration. (See Template::Manual::Config for the details). Configuring the template engine within your app may allow you to do what you want: eg ( warning - untested config!! )
set engines => { template => { template_toolkit => INCLUDE_PATH => [ sub { # code that returns absolute paths to your view dirs map { path( app->location, $_) } 'views', app->request->var('other_views'); }], ... } }; set template => 'template_toolkit';
That sounded like a good idea, but unfortunately it throws an exception:
Can't call method "params" on an undefined value at .../Dancer2/Core/Role/Template.pm line 180.
It happens even on Dancer2 app that I've just created using dancer2 -a where I've removed the template entry from the config.yml and added this to the code:
hook before => sub { set engines => { template => { template_toolkit => { start_tag => '<%', end_tag => '%>', } } }; set template => "template_toolkit"; };
Gabor