Hi guys,
The template layout is bound to the current application. This makes it useful only if you change applications. In the following example switching layouts will work:
# ==== File A.pm ====
package A;
use Dancer ':syntax';
layout 'main';
get '/' => sub { template 'index' };
load_app 'A::B';
true;
# ==== File A/B.pm ====
package A::B;
use Dancer ':syntax';
layout 'users';
get '/users' => sub { template 'users_index' };
true;
The following is an example where switching layouts will NOT work:
# ==== File C.pm ====
package C;
use Dancer ':syntax';
layout 'main';
get '/' => sub { template 'index' };
layout 'users';
get '/users' => sub { template 'users_index' };
true;
In the above situation the layout won't get changed.
I think the layout setting should be bound to each route. When a new route registers it should know what layout was selected last. I think it will make more sense this way.
Regards,
Nick aka minimalist