[dancer-users] Who is using [%prefix%] in templates?

Henk van Oers hvo.pm at xs4all.nl
Mon Sep 30 14:01:45 BST 2013


On Mon, 30 Sep 2013, Alexis Sukrieh wrote:

> 2013/9/29 Henk van Oers <hvo.pm at xs4all.nl>
>
>       I do. I have a hook:
>
>       hook before_template => sub {
>           my $tokens = shift;
>           $tokens->{prefix} = prefix;
>       };
> 
> 
> Hmm, should't it be better to use [% request.uri_base %] ?

No. I mean the part behind the base and before the route: the prefix.

In App:

load_app 'Subapp', prefix => '/foo';

In Subapp:

get '/bar' => sub { template 'bar'; };

In bar.tt

<a href="[%prefix%]/baz">Baz</a>

to get a link to Subaps /baz route from whatever prefix is set to.

HTH
Regards,
Henk


More information about the dancer-users mailing list