line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# ABSTRACT: Markapl template plugin for Mojolicious |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
package Mojolicious::Plugin::MarkaplRenderer; |
4
|
|
|
|
|
|
|
BEGIN { |
5
|
1
|
|
|
1
|
|
516
|
$Mojolicious::Plugin::MarkaplRenderer::VERSION = '0.2.0'; |
6
|
|
|
|
|
|
|
} |
7
|
1
|
|
|
1
|
|
6
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
24
|
|
8
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
30
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
=head1 NAME |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
Mojolicious::Plugin::MarkaplRenderer - Markapl template plugin for Mojolicious |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
=head1 VERSION |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
version 0.2.0 |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
=head1 DESCRIPTION |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
This is L for L. |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
=head1 SYNOPSIS |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
# In app |
25
|
|
|
|
|
|
|
sub startup { |
26
|
|
|
|
|
|
|
my $self = shift; |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
$self->plugins->register_plugin('Mojolicious::Plugin::MarkaplRenderer', $self, view_class => 'MyProject::View'); |
29
|
|
|
|
|
|
|
$self->renderer->default_handler('markapl'); |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
# Then in MyProject::View |
33
|
|
|
|
|
|
|
package MyProject::View; |
34
|
|
|
|
|
|
|
use Markapl; |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
template 'index/index' => sub { |
37
|
|
|
|
|
|
|
html { |
38
|
|
|
|
|
|
|
head { |
39
|
|
|
|
|
|
|
meta(charset => 'UTF-8'); |
40
|
|
|
|
|
|
|
title { 'I am title' }; |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
body { |
44
|
|
|
|
|
|
|
p { 'testing paragraph...' }; |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
# ... |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
}; |
49
|
|
|
|
|
|
|
}; |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
1; |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
=cut |
54
|
|
|
|
|
|
|
|
55
|
1
|
|
|
1
|
|
999
|
use Mojo::Base 'Mojolicious::Plugin'; |
|
1
|
|
|
|
|
11256
|
|
|
1
|
|
|
|
|
7
|
|
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
sub register { |
58
|
0
|
|
|
0
|
1
|
|
my ($self, $app, $conf) = @_; |
59
|
|
|
|
|
|
|
|
60
|
0
|
|
0
|
|
|
|
$conf ||= {}; |
61
|
0
|
|
0
|
|
|
|
my $name = $conf->{name} || 'markapl'; |
62
|
|
|
|
|
|
|
|
63
|
0
|
|
|
|
|
|
my $view_class = $conf->{view_class}; |
64
|
0
|
|
|
|
|
|
eval "require $view_class;"; |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
$app->renderer->add_handler( |
67
|
|
|
|
|
|
|
$name => sub { |
68
|
0
|
|
|
0
|
|
|
my ($r, $c, $output, $options) = @_; |
69
|
|
|
|
|
|
|
|
70
|
0
|
|
|
|
|
|
$$output = $view_class->render($options->{template}, $c->{stash}); |
71
|
|
|
|
|
|
|
|
72
|
0
|
|
|
|
|
|
return 1; |
73
|
|
|
|
|
|
|
} |
74
|
0
|
|
|
|
|
|
); |
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
=head1 AUTHOR |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
Gea-Suan Lin, C<< >> |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
=head1 LICENSE AND COPYRIGHT |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
Copyright 2011 Gea-Suan Lin. |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
This software is released under 3-clause BSD license. See |
86
|
|
|
|
|
|
|
L for more |
87
|
|
|
|
|
|
|
information. |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
=cut |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
1; |