blob: ee37aaa8c41a0789684b3204307517628dce7597 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
|
package Dancer::Template::Declare;
use strict;
use warnings;
use base 'Dancer::Template::Abstract';
use Template::Declare;
my $_init;
sub init {
my $self = shift;
$_init = $self->{config};
}
sub view { return $_[1] }
sub layout { return $_[3] }
sub render {
my ($self, $template, $token) = @_;
Template::Declare->init( %{ $_init } );
Template::Declare->show($template, $token);
}
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
|