[Dancer-users] Dancer: allow multiple folders for Template's INCLUDE_PATH

Alexis Sukrieh sukria at sukria.net
Fri Apr 30 11:58:12 CEST 2010


[CC'ing the list / please, send this kind of messages to the list next 
times, thanks]

Stéphane a écrit :
> It would be nice to be able to specify multiple folders for 
> setting('views'), but that would require some extensive changes 
> (changing template() is simple enough, but a lot of spots in Dancer's 
> code assume 'views' is a scalar, not an array).

Well, this doesn't fit the convetions Dancer is based on, I'm not sure 
why you want to do that (you can still create multiple directories 
inside the 'views' dir).

> Would it be possible however to allow Template's INCLUDE_PATH to be 
> specified in the regular manner (using the "template_toolkit" engine 
> YAML configuration) and Dancer's default path to be pre-pended?

Yes, this is a good idea, more generally, any TT config given in the 
configuration should be used prior to Dancer's defaults.

> E.g. replace
> 
>     $tt_config->{INCLUDE_PATH} = setting('views');
> 
> in Dancer::Template::TemplateToolkit with:
> 
>     if($tt_config->{INCLUDE_PATH}) {
>       if(ref($tt_config->{INCLUDE_PATH}) eq 'ARRAY') {
>         unshift @{$tt_config->{INCLUDE_PATH}}, setting('views');
>       } else {
>         $tt_config->{INCLUDE_PATH} =
>            [setting('views'),$tt_config->{INCLUDE_PATH}];
>       }
>     } else {
>       $tt_config->{INCLUDE_PATH} = setting('views');
>     }

Hmm, no. There are different things you're talking about there:

1. the setting "views" which you want to be an ARRAY instead of a SCALAR.
2. the facility of changing TT's INCLUDE_PATH setting.

I disagree with (1) for the reasons explained above. I agree with (2) 
but the user should be warned in some way that he might break something. 
Anyways, it's a sane idea to let them change whatever TT config they 
want via Dancer's engine config.

If the user change the INCLUDE_PATH setting and don't include the 
"views" directory

On the other hand, the "views" setting should remain a scalar to me, as 
this is one of Dancer's conventions: "views are located in a directory".

> (I'm assuming that the paths will be specified in a YAML array if there 
> are more than one.)
> 
> Again probably not a feature a lot of people are looking for, especially 
> if they deploy only once, but this allows me to separate generic views 
> from views that apply to a specific installation.

To conclude, I think you should fill an issue report like "propagate all 
TT config entries from Dancer's configuration to TT's" so we can track 
the work on this more easily.

Regards,

-- 
Alexis Sukrieh


More information about the Dancer-users mailing list