Who is using [%prefix%] in templates?
I do. I have a hook: hook before_template => sub { my $tokens = shift; $tokens->{prefix} = prefix; }; Is this a good candidate to implement in https://metacpan.org/module/Dancer::Template::Abstract as default Dancer inject like qw(perl_version dancer_version settings request params vars session); ? -- Henk
As for me - it's too long. May be it's better to write middleware content filter and rewrite all absolute URLs? 30.09.2013 16:06, Alexis Sukrieh пишет:
Hi,
2013/9/29 Henk van Oers <hvo.pm@xs4all.nl <mailto:hvo.pm@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 %] ?
-- Best Regards, Nick Knutov http://knutov.com ICQ: 272873706 Voice: +7-904-84-23-130
On Mon, 30 Sep 2013, Alexis Sukrieh wrote:
2013/9/29 Henk van Oers <hvo.pm@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
On 13-09-29 09:07 AM, Henk van Oers wrote:
Is this a good candidate to implement in https://metacpan.org/module/Dancer::Template::Abstract as default Dancer inject like qw(perl_version dancer_version settings request params vars session); ?
I can see how it can be very useful in cases where you want to abstract the prefix from the urls in the template, but I'm not sure that it's something that people to often enough to warrant to always have it as part of the defaults. Mostly considering how easy it is to add it via the hook like you did. Joy, `/anick
On Thu, 3 Oct 2013, Yanick Champoux wrote:
On 13-09-29 09:07 AM, Henk van Oers wrote:
Is this a good candidate to implement in https://metacpan.org/module/Dancer::Template::Abstract as default Dancer inject like qw(perl_version dancer_version settings request params vars session); ?
I can see how it can be very useful in cases where you want to abstract the prefix from the urls in the template, but I'm not sure that it's something that people to often enough to warrant to always have it as part of the defaults. Mostly considering how easy it is to add it via the hook like you did.
OK. Maybe something for Dancer::Cookbook or Advent calendar then. Regards, Henk van Oers
participants (4)
-
Alexis Sukrieh -
Henk van Oers -
Nick Knutov -
Yanick Champoux