line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Dancer::Plugin::TagHelper; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
33306
|
use 5.006; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
74
|
|
4
|
1
|
|
|
1
|
|
8
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
44
|
|
5
|
1
|
|
|
1
|
|
7
|
use warnings FATAL => 'all'; |
|
1
|
|
|
|
|
14
|
|
|
1
|
|
|
|
|
56
|
|
6
|
1
|
|
|
1
|
|
2871
|
use Dancer ':syntax'; |
|
1
|
|
|
|
|
394532
|
|
|
1
|
|
|
|
|
5
|
|
7
|
1
|
|
|
1
|
|
1029
|
use HTML::TagHelper; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
=head1 NAME |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
Dancer::Plugin::TagHelper - Useful routines for generating HTML for use with Dancer + TT/Xslate ... |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
=head1 VERSION |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
Version 0.01 |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
=cut |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
our $VERSION = '0.01'; |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
=head1 SYNOPSIS |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
In your Dancer application's MyApp.pm file ... |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
use Dancer::Plugin::TagHelper; |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
and in your application's views ... |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
<: css('bootstrap') :> |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
or |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
<% js(jquery) %> |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
=cut |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
my %methods; |
39
|
|
|
|
|
|
|
my $ht = HTML::TagHelper->new(); |
40
|
|
|
|
|
|
|
for my $method ( $ht->meta->get_all_methods ) { |
41
|
|
|
|
|
|
|
next if $method->fully_qualified_name !~ /^HTML::TagHelper::[a-z]/; |
42
|
|
|
|
|
|
|
$methods{ $method->name } = $method; |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
delete $methods{$_} for qw/after around extends has before with new/; |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
my $template = setting('template'); |
47
|
|
|
|
|
|
|
if ( $template eq 'simple' ) { |
48
|
|
|
|
|
|
|
warn "$template donot support taghelper"; |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
elsif ( $template eq 'xslate' ) { |
51
|
|
|
|
|
|
|
my $functions; |
52
|
|
|
|
|
|
|
for my $name ( keys %methods ) { |
53
|
|
|
|
|
|
|
my $method = $methods{$name}; |
54
|
|
|
|
|
|
|
$functions->{$name} = Text::Xslate::html_builder(sub { $method->execute( $ht, @_ ) }); |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
set engines => { |
57
|
|
|
|
|
|
|
xslate => { |
58
|
|
|
|
|
|
|
function => $functions |
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
}; |
61
|
|
|
|
|
|
|
}; |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
hook 'before_template' => sub { |
65
|
|
|
|
|
|
|
my $tokens = shift; |
66
|
|
|
|
|
|
|
for my $name ( keys %methods ) { |
67
|
|
|
|
|
|
|
my $method = $methods{$name}; |
68
|
|
|
|
|
|
|
$tokens->{$name} = sub { $method->execute( $ht, @_ ) }; |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
}; |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
=head1 AUTHOR |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
chenryn, C<< >> |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
=head1 BUGS |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
Please report any bugs or feature requests to C, or through |
80
|
|
|
|
|
|
|
the web interface at L. I will be notified, and then you'll |
81
|
|
|
|
|
|
|
automatically be notified of progress on your bug as I make changes. |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
By now, you must set template in C, but not set by C<< set template => ''>> in c<>. |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
=head1 SUPPORT |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
You can find documentation for this module with the perldoc command. |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
perldoc Dancer::Plugin::TagHelper |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
You can also look for information at: |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
=over 4 |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
=item * RT: CPAN's request tracker (report bugs here) |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
L |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
=item * AnnoCPAN: Annotated CPAN documentation |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
L |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
=item * CPAN Ratings |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
L |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
=item * Search CPAN |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
L |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
=back |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
=head1 ACKNOWLEDGEMENTS |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
=head1 LICENSE AND COPYRIGHT |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
Copyright 2013 chenryn. |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it |
124
|
|
|
|
|
|
|
under the terms of the the Artistic License (2.0). You may obtain a |
125
|
|
|
|
|
|
|
copy of the full license at: |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
L |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
Any use, modification, and distribution of the Standard or Modified |
130
|
|
|
|
|
|
|
Versions is governed by this Artistic License. By using, modifying or |
131
|
|
|
|
|
|
|
distributing the Package, you accept this license. Do not use, modify, |
132
|
|
|
|
|
|
|
or distribute the Package, if you do not accept this license. |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
If your Modified Version has been derived from a Modified Version made |
135
|
|
|
|
|
|
|
by someone other than you, you are nevertheless required to ensure that |
136
|
|
|
|
|
|
|
your Modified Version complies with the requirements of this license. |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
This license does not grant you the right to use any trademark, service |
139
|
|
|
|
|
|
|
mark, tradename, or logo of the Copyright Holder. |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
This license includes the non-exclusive, worldwide, free-of-charge |
142
|
|
|
|
|
|
|
patent license to make, have made, use, offer to sell, sell, import and |
143
|
|
|
|
|
|
|
otherwise transfer the Package with respect to any patent claims |
144
|
|
|
|
|
|
|
licensable by the Copyright Holder that are necessarily infringed by the |
145
|
|
|
|
|
|
|
Package. If you institute patent litigation (including a cross-claim or |
146
|
|
|
|
|
|
|
counterclaim) against any party alleging that the Package constitutes |
147
|
|
|
|
|
|
|
direct or contributory patent infringement, then this Artistic License |
148
|
|
|
|
|
|
|
to you shall terminate on the date that such litigation is filed. |
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
Disclaimer of Warranty: THE PACKAGE IS PROVIDED BY THE COPYRIGHT HOLDER |
151
|
|
|
|
|
|
|
AND CONTRIBUTORS "AS IS' AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES. |
152
|
|
|
|
|
|
|
THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR |
153
|
|
|
|
|
|
|
PURPOSE, OR NON-INFRINGEMENT ARE DISCLAIMED TO THE EXTENT PERMITTED BY |
154
|
|
|
|
|
|
|
YOUR LOCAL LAW. UNLESS REQUIRED BY LAW, NO COPYRIGHT HOLDER OR |
155
|
|
|
|
|
|
|
CONTRIBUTOR WILL BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, OR |
156
|
|
|
|
|
|
|
CONSEQUENTIAL DAMAGES ARISING IN ANY WAY OUT OF THE USE OF THE PACKAGE, |
157
|
|
|
|
|
|
|
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
=cut |
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
1; # End of Dancer::Plugin::TagHelper |