[dancer-users] Having multiple INCLUDE_PATH for the Template Toolkit engine

Russell Jenkins russell.jenkins at strategicdata.com.au
Tue Nov 10 13:18:23 GMT 2015


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';


Hope that helps,
   Russell.



More information about the dancer-users mailing list