On Tue, Nov 10, 2015 at 3:18 PM, Russell Jenkins <
[email protected]> 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
_______________________________________________
dancer-users mailing list
[email protected]
http://lists.preshweb.co.uk/mailman/listinfo/dancer-users

Reply via email to