| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Template::Caribou; |
|
2
|
|
|
|
|
|
|
our $AUTHORITY = 'cpan:YANICK'; |
|
3
|
|
|
|
|
|
|
# ABSTRACT: class-based HTML-centric templating system |
|
4
|
|
|
|
|
|
|
$Template::Caribou::VERSION = '1.2.1'; |
|
5
|
11
|
|
|
11
|
|
738366
|
use Carp; |
|
|
11
|
|
|
|
|
16
|
|
|
|
11
|
|
|
|
|
665
|
|
|
6
|
|
|
|
|
|
|
|
|
7
|
11
|
|
|
11
|
|
3030
|
use Moose::Exporter; |
|
|
11
|
|
|
|
|
674370
|
|
|
|
11
|
|
|
|
|
64
|
|
|
8
|
|
|
|
|
|
|
|
|
9
|
11
|
|
|
11
|
|
3994
|
use Template::Caribou::Role; |
|
|
11
|
|
|
|
|
29
|
|
|
|
11
|
|
|
|
|
39
|
|
|
10
|
11
|
|
|
11
|
|
4753
|
use Template::Caribou::Tags qw/ attr /; |
|
|
11
|
|
|
|
|
13
|
|
|
|
11
|
|
|
|
|
41
|
|
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
Moose::Exporter->setup_import_methods( |
|
13
|
|
|
|
|
|
|
with_meta => [ 'template' ], |
|
14
|
|
|
|
|
|
|
as_is => [ 'attr', 'show' ], |
|
15
|
|
|
|
|
|
|
also => [ 'Template::Caribou::Role' ], |
|
16
|
|
|
|
|
|
|
); |
|
17
|
|
|
|
|
|
|
|
|
18
|
11
|
|
|
11
|
|
1743
|
use Moose::Util qw/ apply_all_roles /; |
|
|
11
|
|
|
|
|
15
|
|
|
|
11
|
|
|
|
|
80
|
|
|
19
|
|
|
|
|
|
|
|
|
20
|
11
|
|
|
11
|
|
1650
|
use 5.10.0; |
|
|
11
|
|
|
|
|
25
|
|
|
21
|
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
sub show { |
|
23
|
0
|
|
|
0
|
0
|
0
|
state $shown_warning = 0; |
|
24
|
|
|
|
|
|
|
|
|
25
|
0
|
0
|
|
|
|
0
|
carp 'show() is deprecated, use $bou->my_template instead' |
|
26
|
|
|
|
|
|
|
unless $shown_warning++; |
|
27
|
|
|
|
|
|
|
|
|
28
|
0
|
|
|
|
|
0
|
$Template::Caribou::TEMPLATE->render(@_); |
|
29
|
|
|
|
|
|
|
} |
|
30
|
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
sub init_meta { |
|
32
|
15
|
|
|
15
|
0
|
11648
|
my $class = shift; |
|
33
|
15
|
|
|
|
|
49
|
my %args = @_; |
|
34
|
|
|
|
|
|
|
|
|
35
|
15
|
|
|
|
|
23
|
my $meta = eval { $args{for_class}->meta }; |
|
|
15
|
|
|
|
|
188
|
|
|
36
|
|
|
|
|
|
|
|
|
37
|
15
|
100
|
|
|
|
112
|
unless ( $meta ) { |
|
38
|
11
|
|
|
|
|
68
|
$meta = Moose->init_meta(@_); |
|
39
|
11
|
|
|
11
|
|
51
|
eval "package $args{for_class}; use Moose;"; |
|
|
11
|
|
|
|
|
18
|
|
|
|
11
|
|
|
|
|
54
|
|
|
|
11
|
|
|
|
|
40841
|
|
|
40
|
|
|
|
|
|
|
} |
|
41
|
|
|
|
|
|
|
|
|
42
|
15
|
|
|
|
|
14155
|
apply_all_roles( $args{for_class}, 'Template::Caribou::Role' ); |
|
43
|
|
|
|
|
|
|
|
|
44
|
15
|
|
|
|
|
32712
|
return $meta; |
|
45
|
|
|
|
|
|
|
} |
|
46
|
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
1; |
|
48
|
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
__END__ |
|
50
|
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
=pod |
|
52
|
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
=encoding UTF-8 |
|
54
|
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
=head1 NAME |
|
56
|
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
Template::Caribou - class-based HTML-centric templating system |
|
58
|
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
=head1 VERSION |
|
60
|
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
version 1.2.1 |
|
62
|
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
64
|
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
package MyTemplate; |
|
66
|
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
use Template::Caribou; |
|
68
|
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
use Template::Caribou::Tags::HTML qw/ :all /; |
|
70
|
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
has name => ( is => 'ro' ); |
|
72
|
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
template page => sub { |
|
74
|
|
|
|
|
|
|
my $self = shift; |
|
75
|
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
html { |
|
77
|
|
|
|
|
|
|
head { |
|
78
|
|
|
|
|
|
|
title { 'Example' } |
|
79
|
|
|
|
|
|
|
}; |
|
80
|
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
$self->my_body; |
|
82
|
|
|
|
|
|
|
} |
|
83
|
|
|
|
|
|
|
}; |
|
84
|
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
template my_body => sub { |
|
86
|
|
|
|
|
|
|
my $self = shift; |
|
87
|
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
body { |
|
89
|
|
|
|
|
|
|
h1 { 'howdie ' . $self->name } |
|
90
|
|
|
|
|
|
|
} |
|
91
|
|
|
|
|
|
|
}; |
|
92
|
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
package main; |
|
94
|
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
my $template = MyTemplate->new( name => 'Yanick' ); |
|
96
|
|
|
|
|
|
|
print $template->page; |
|
97
|
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
99
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
WARNING: Codebase is alpha with extreme prejudice. Assume that bugs are |
|
101
|
|
|
|
|
|
|
teeming and that the API is subject to change. |
|
102
|
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
L<Template::Caribou> is a L<Moose>-based, class-centric templating system |
|
104
|
|
|
|
|
|
|
mostly aimed at producing sgml-like outputs, mostly HTML, but also XML, SVG, etc. It is |
|
105
|
|
|
|
|
|
|
heavily inspired by L<Template::Declare>. |
|
106
|
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
For a manual on how to use C<Template::Caribou>, have a peek at |
|
108
|
|
|
|
|
|
|
L<Template::Caribou::Manual>. |
|
109
|
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
When C<use>d within a namespace, C<Template::Caribou> will apply the role L<Template::Caribou::Role> |
|
111
|
|
|
|
|
|
|
to it (and auto-turn the namespace into Moose class if it wasn't a Moose class or role already), |
|
112
|
|
|
|
|
|
|
as well as import the keywords C<template> and C<attr> (the latter from |
|
113
|
|
|
|
|
|
|
L<Template::Caribou::Tags>), as well as load L<Template::Caribou::Utils>. |
|
114
|
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
=head1 AUTHOR |
|
116
|
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
Yanick Champoux <yanick@cpan.org> |
|
118
|
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
|
120
|
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
This software is copyright (c) 2017 by Yanick Champoux. |
|
122
|
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
|
124
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
|
125
|
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
=cut |