[Dancer-users] Template layout

igor.bujna at post.cz igor.bujna at post.cz
Sat Oct 2 14:27:33 CEST 2010


Hi,
i now read every documentation about parameters to 'template' and there is, for disable layout I make this one:

template 'index.tt', {}, { layout => undef };

Standart use standart layout from config.yml. My idea, is use for some request own or other layout. Now must be some hack to change $app->setting{layout}. I think there was simplest way when you put this my patch. Now in parameter in template, you can use own layout in layout directory. Such as use views/layouts/simple.tt 

template 'index.tt', {}, { layout => 'simple'};

--- Helpers.pm~ 2010-10-02 14:16:14.000000000 +0200
+++ Helpers.pm  2010-10-02 14:17:06.000000000 +0200
@@ -34,9 +34,8 @@

     my $app = Dancer::App->current;

-    $options ||= {layout => 1};
-    my $layout = $app->setting('layout');
-    undef $layout unless $options->{layout};
+    $options ||= {};
+    my $layout = exists($options->{layout} ? $options->{layout} : $app->setting('layout');

     $tokens ||= {};
     $tokens->{settings} = Dancer::Config->settings;


More information about the Dancer-users mailing list