<div dir="ltr"><div><div>Opened a ticket with this including a test case. <a href="https://github.com/PerlDancer/Dancer2/issues/1059">https://github.com/PerlDancer/Dancer2/issues/1059</a><br></div>It would be nice if someone could review it.<br><br></div>Gabor<br><br><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Nov 12, 2015 at 5:00 PM, Gabor Szabo <span dir="ltr"><<a href="mailto:gabor@szabgab.com" target="_blank">gabor@szabgab.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote"><span class="">On Tue, Nov 10, 2015 at 3:18 PM, Russell Jenkins <span dir="ltr"><<a href="mailto:russell.jenkins@strategicdata.com.au" target="_blank">russell.jenkins@strategicdata.com.au</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><span>On 10/11/2015 6:06 pm, Gabor Szabo wrote:<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
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?<br>
<br>
</blockquote>
<br></span>
Allowing views to be an arrayref of strings is likely to cause issues with other template engines.<br>
<br>
TT2 allows you to supply coderefs as part of its INCLUDE_PATH configuration.<br>
(See Template::Manual::Config for the details). Configuring the template engine within<br>
your app may allow you to do what you want: eg ( warning - untested config!! )<br>
<br>
set engines => {<br>
template => {<br>
template_toolkit =><br>
INCLUDE_PATH => [ sub {<br>
# code that returns absolute paths to your view dirs<br>
map { path( app->location, $_) }<br>
'views', app->request->var('other_views');<br>
}],<br>
...<br>
}<br>
};<br>
set template => 'template_toolkit';<br>
<br><br></blockquote><div><br></div></span><div>That sounded like a good idea, but unfortunately it throws an exception:<br><br><pre>Can't call method "params" on an undefined value at .../Dancer2/Core/Role/Template.pm line 180.<br><br><br></pre>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:<br><br>hook before => sub {<span class=""><br> set engines => {<br> template => {<br></span> template_toolkit => {<br> start_tag => '<%',<br> end_tag => '%>',<br> }<br> }<br> };<br> set template => "template_toolkit";<br>};<br><br><br>Gabor<br><br></div></div></div></div></blockquote></div></div></div>