diff options
-rw-r--r-- | lib/Dancer/Template/Declare.pm | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/lib/Dancer/Template/Declare.pm b/lib/Dancer/Template/Declare.pm index 8816ecd..ee37aaa 100644 --- a/lib/Dancer/Template/Declare.pm +++ b/lib/Dancer/Template/Declare.pm @@ -23,3 +23,41 @@ sub render { } 1; + +=head1 SYNOPSIS + + package myapp::templates; + use Template::Declare::Tags; + use base 'Template::Declare'; + + template hello => sub { + my ($self, $vars) = @_; + html { + head { + title {"Hello, $vars->{user}"}; + }; + body { + h1 { + "Hello, $vars->{user}"; + }; + }; + }; + }; + + package myapp; + use myapp::templates; + use Dancer ':syntax'; + + get '/' => sub { + template 'hello', {user => 'marc'}; + }; + + true; + + # in your configuration: + template: declare + engines: + declare: + dispatch_to: + - myapp::template + |