File Coverage

blib/lib/MojoX/CustomTemplateFileParser/Plugin/To/Html.pm
Criterion Covered Total %
statement 37 37 100.0
branch 5 6 83.3
condition n/a
subroutine 5 5 100.0
pod 1 1 100.0
total 48 49 97.9


line stmt bran cond sub pod time code
1             package MojoX::CustomTemplateFileParser::Plugin::To::Html;
2              
3 1     1   5058 use strict;
  1         2  
  1         26  
4 1     1   6 use warnings;
  1         1  
  1         31  
5 1     1   13 use 5.10.1;
  1         3  
6              
7             our $VERSION = '0.1002'; # VERSION
8             # ABSTRACT: Create html
9              
10 1     1   5 use Moose::Role;
  1         2  
  1         10  
11              
12             sub to_html {
13 1     1 1 10632 my $self = shift;
14              
15 1         3 my @out = ();
16 1         52 my $tests = $self->structure->{'tests'};
17              
18 1         3 foreach my $test (@{ $tests }) {
  1         5  
19 3         6 push @out => (qq{<div class="panel panel-default"><div class="panel-body">});
20 3 50       4 if(scalar @{ $test->{'lines_before'} }) {
  3         13  
21 3         3 push @out => @{ $test->{'lines_before'} };
  3         9  
22             }
23 3         5 push @out => ('<pre>', HTML::Entities::encode_entities(join("\n" => @{ $test->{'lines_template'} })), '</pre>');
  3         17  
24 3 100       97 if(scalar @{ $test->{'lines_between'} }) {
  3         11  
25 1         3 push @out => @{ $test->{'lines_between'} };
  1         3  
26             }
27 3         6 push @out => ('<pre>', HTML::Entities::encode_entities(join("\n" => @{ $test->{'lines_expected'} })), '</pre>');
  3         13  
28 3 100       102 if(scalar @{ $test->{'lines_after'} }) {
  3         11  
29 1         2 push @out => @{ $test->{'lines_after'} };
  1         4  
30             }
31 3         4 push @out => '<hr />', @{ $test->{'lines_expected'} };
  3         18  
32 3         7 push @out => (qq{</div></div>});
33             }
34              
35 1         15 return join '' => @out;
36             }
37              
38             1;
39              
40             __END__
41              
42             =pod
43              
44             =encoding UTF-8
45              
46             =head1 NAME
47              
48             MojoX::CustomTemplateFileParser::Plugin::To::Html - Create html
49              
50             =head1 VERSION
51              
52             Version 0.1002, released 2015-11-26.
53              
54             =head1 SYNOPSIS
55              
56             use MojoX::CustomTemplateFileParser;
57              
58             my $parser = MojoX::CustomTemplateFileParser->new(path => '/path/to/file.mojo', output => ['Html']);
59              
60             print $parser->to_html;
61              
62             =head1 DESCRIPTION
63              
64             MojoX::CustomTemplateFileParser::Plugin::To::Html is an output plugin to L<MojoX::CustomTemplateFileParser>.
65              
66             =head2 to_html()
67              
68             This method is added to L<MojoX::CustomTemplateFileParser> objects created with C<output =E<gt> ['Html']>.
69              
70             =head1 SEE ALSO
71              
72             =over 4
73              
74             =item *
75              
76             L<Dist::Zilla::Plugin::InsertExample::FromMojoTemplates>
77              
78             =item *
79              
80             L<MojoX::CustomTemplateFileParser::Plugin::To::Pod>
81              
82             =item *
83              
84             L<MojoX::CustomTemplateFileParser::Plugin::To::Test>
85              
86             =back
87              
88             =head1 SOURCE
89              
90             L<https://github.com/Csson/p5-mojox-customtemplatefileparser>
91              
92             =head1 HOMEPAGE
93              
94             L<https://metacpan.org/release/MojoX-CustomTemplateFileParser>
95              
96             =head1 AUTHOR
97              
98             Erik Carlsson <info@code301.com>
99              
100             =head1 COPYRIGHT AND LICENSE
101              
102             This software is copyright (c) 2015 by Erik Carlsson.
103              
104             This is free software; you can redistribute it and/or modify it under
105             the same terms as the Perl 5 programming language system itself.
106              
107             =cut