<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">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 class="">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><div>That sounded like a good idea, but unfortunately it throws an exception:<br><br><pre class="">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 {<br>    set engines => {<br>      template => {<br>        template_toolkit => {<br>          start_tag => '<%',<br>          end_tag   => '%>',<br>        }<br>        }<br>    };<br>    set template => "template_toolkit";<br>};<br><br><br>Gabor<br><pre class=""><br></pre><br></div><div><br><br> </div></div></div></div>