File Coverage

blib/lib/Form/Processor/Field/Template.pm
Criterion Covered Total %
statement 17 17 100.0
branch 3 4 75.0
condition n/a
subroutine 5 5 100.0
pod 1 1 100.0
total 26 27 96.3


line stmt bran cond sub pod time code
1             package Form::Processor::Field::Template;
2             $Form::Processor::Field::Template::VERSION = '1.162360';
3 1     1   537 use strict;
  1         1  
  1         25  
4 1     1   2 use warnings;
  1         1  
  1         26  
5              
6              
7             # This doesn't work because need to transform the input data before can validate
8             # and the Form module doesn't support this.
9             # Also, not all template snippets are valid HTML
10             # Since it doesn't work then can simply use Template::Parser to validate
11             # the templates.
12              
13             # use base 'Form::Processor::Field::HtmlArea';
14              
15              
16 1     1   3 use base 'Form::Processor::Field::TextArea';
  1         0  
  1         365  
17              
18             # use HTML::Tidy;
19 1     1   7 use Template::Parser;
  1         2  
  1         77  
20              
21              
22             # Checks that the template compiles and validates.
23              
24              
25             sub validate {
26 2     2 1 2 my $field = shift;
27              
28 2 50       5 return unless $field->SUPER::validate;
29              
30 2         7 my $parser = Template::Parser->new;
31              
32 2 100       246 return $field->add_error( 'Template Error: [_1]', $parser->error )
33             unless $parser->parse( $field->input );
34              
35 1         621 return 1;
36              
37             }
38              
39              
40              
41             # ABSTRACT: Tests that Template-Toolkit can parse the content
42              
43              
44              
45              
46             1;
47              
48             =pod
49              
50             =encoding UTF-8
51              
52             =head1 NAME
53              
54             Form::Processor::Field::Template - Tests that Template-Toolkit can parse the content
55              
56             =head1 VERSION
57              
58             version 1.162360
59              
60             =head1 SYNOPSIS
61              
62             See L
63              
64             =head1 DESCRIPTION
65              
66             This is a subclass of a TextArea field and the content of the field is parsed with
67             L for validation.
68              
69             =head2 Widget
70              
71             Fields can be given a widget type that is used as a hint for
72             the code that renders the field.
73              
74             This field's widget type is: "textarea".
75              
76             =head2 Subclass
77              
78             Fields may inherit from other fields. This field
79             inherits from: "TextArea".
80              
81             =head1 SUPPORT / WARRANTY
82              
83             L is free software and is provided WITHOUT WARRANTY OF ANY KIND.
84             Users are expected to review software for fitness and usability.
85              
86             =head1 AUTHOR
87              
88             Bill Moseley
89              
90             =head1 COPYRIGHT AND LICENSE
91              
92             This software is copyright (c) 2012 by Bill Moseley.
93              
94             This is free software; you can redistribute it and/or modify it under
95             the same terms as the Perl 5 programming language system itself.
96              
97             =cut
98              
99             __END__