File Coverage

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


line stmt bran cond sub pod time code
1             package MojoX::CustomTemplateFileParser::Plugin::To::Html;
2              
3 1     1   5678 use strict;
  1         2  
  1         40  
4 1     1   7 use warnings;
  1         1  
  1         33  
5 1     1   15 use 5.10.1;
  1         3  
  1         71  
6             our $VERSION = '0.10';
7              
8 1     1   7 use Moose::Role;
  1         2  
  1         11  
9              
10             sub to_html {
11 1     1 1 18394 my $self = shift;
12              
13 1         4 my @out = ();
14 1         53 my $tests = $self->structure->{'tests'};
15              
16 1         3 foreach my $test (@{ $tests }) {
  1         6  
17 3         7 push @out => (qq{<div class="panel panel-default"><div class="panel-body">});
18 3 50       3 if(scalar @{ $test->{'lines_before'} }) {
  3         14  
19 3         4 push @out => @{ $test->{'lines_before'} };
  3         8  
20             }
21 3         5 push @out => ('<pre>', HTML::Entities::encode_entities(join("\n" => @{ $test->{'lines_template'} })), '</pre>');
  3         18  
22 3 100       94 if(scalar @{ $test->{'lines_between'} }) {
  3         14  
23 1         2 push @out => @{ $test->{'lines_between'} };
  1         4  
24             }
25 3         5 push @out => ('<pre>', HTML::Entities::encode_entities(join("\n" => @{ $test->{'lines_expected'} })), '</pre>');
  3         15  
26 3 100       99 if(scalar @{ $test->{'lines_after'} }) {
  3         12  
27 1         2 push @out => @{ $test->{'lines_after'} };
  1         5  
28             }
29 3         5 push @out => '<hr />', @{ $test->{'lines_expected'} };
  3         10  
30 3         8 push @out => (qq{</div></div>});
31             }
32              
33 1         15 return join '' => @out;
34             }
35              
36             1;
37              
38             =encoding utf-8
39              
40             =head1 NAME
41              
42             MojoX::CustomTemplateFileParser::Plugin::To::Html - Create html
43              
44             =head1 SYNOPSIS
45              
46             use MojoX::CustomTemplateFileParser;
47              
48             my $parser = MojoX::CustomTemplateFileParser->new(path => '/path/to/file.mojo', output => ['Html']);
49              
50             print $parser->to_html;
51              
52             =head1 DESCRIPTION
53              
54             MojoX::CustomTemplateFileParser::Plugin::To::Html is an output plugin to L<MojoX::CustomTemplateFileParser>.
55              
56             =head2 to_html()
57              
58             This method is added to L<MojoX::CustomTemplateFileParser> objects created with C<output =E<gt> ['Html']>.
59              
60             =head1 SEE ALSO
61              
62             =over 4
63              
64             =item * L<Dist::Zilla::Plugin::InsertExample::FromMojoTemplates>
65              
66             =item * L<MojoX::CustomTemplateFileParser::Plugin::To::Pod>
67              
68             =item * L<MojoX::CustomTemplateFileParser::Plugin::To::Test>
69              
70             =back
71              
72             =head1 AUTHOR
73              
74             Erik Carlsson E<lt>info@code301.comE<gt>
75              
76             =head1 COPYRIGHT
77              
78             Copyright 2014- Erik Carlsson
79              
80             =head1 LICENSE
81              
82             This library is free software; you can redistribute it and/or modify
83             it under the same terms as Perl itself.
84              
85             =cut