| 1 | # ABSTRACT: Markapl template plugin for Mojolicious | ||||||||||||
| 2 | |||||||||||||
| 3 | package Mojolicious::Plugin::MarkaplRenderer; | ||||||||||||
| 4 | 1 | ▶ | BEGIN { | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 5 | 1 | $Mojolicious::Plugin::MarkaplRenderer::VERSION = '0.2.0'; | |||||||||||
| 6 | } | ||||||||||||
| 7 | 1 | ▶ | use strict; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 8 | 1 | ▶ | use warnings; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 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<Markapl> for L<Mojolicious>. | ||||||||||||
| 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 | ▶ | use Mojo::Base 'Mojolicious::Plugin'; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 56 | |||||||||||||
| 57 | 0 | ▶ | sub register { | ||||||||||
|
Subroutine
register: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||
| 58 | 0 | my ($self, $app, $conf) = @_; | |||||||||||
| 59 | |||||||||||||
| 60 | 0 | ▶ | $conf ||= {}; | ||||||||||
|
Condition0%0/2
$conf ||= {}
MC/DC0%0/1
$conf ||= {}
$conf
Truth table0%0/2
A
A= $conf
| |||||||||||||
| 61 | 0 | ▶ | my $name = $conf->{name} || 'markapl'; | ||||||||||
|
Condition0%0/2
$conf->{'name'} || 'markapl'
MC/DC0%0/1
$conf->{'name'} || 'markapl'
$conf->{'name'}
Truth table0%0/2
A
A= $conf->{'name'}
| |||||||||||||
| 62 | |||||||||||||
| 63 | 0 | my $view_class = $conf->{view_class}; | |||||||||||
| 64 | 0 | eval "require $view_class;"; | |||||||||||
| 65 | |||||||||||||
| 66 | $app->renderer->add_handler( | ||||||||||||
| 67 | 0 | ▶ | $name => sub { | ||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||
| 68 | 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<< <gslin at gslin.org> >> | ||||||||||||
| 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<http://www.opensource.org/licenses/bsd-license.php> for more | ||||||||||||
| 87 | information. | ||||||||||||
| 88 | |||||||||||||
| 89 | =cut | ||||||||||||
| 90 | |||||||||||||
| 91 | 1 | 1; | |||||||||||