File Coverage

blib/lib/Template/LiquidX/Tidy/Liquid/Utility.pm
Criterion Covered Total %
statement 14 14 100.0
branch 2 2 100.0
condition 1 2 50.0
subroutine 5 5 100.0
pod 0 1 0.0
total 22 24 91.6


line stmt bran cond sub pod time code
1             use strict;
2 3     3   19 use warnings;
  3         5  
  3         93  
3 3     3   14 use Template::Liquid::Utility;
  3         4  
  3         73  
4 3     3   1129  
  3         4043  
  3         1566  
5             our $VERSION = '1.0.10';
6             $Template::Liquid::Utility::FilterSeparator = qr[\s*\|\s*]o;
7             my $ArgumentSeparator = qr[,]o;
8             $Template::Liquid::Utility::FilterArgumentSeparator = qr[\s*:\s*]o;
9             $Template::Liquid::Utility::VariableAttributeSeparator = qr[\.]o;
10             $Template::Liquid::Utility::TagStart = qr[{%-?\s*]o;
11             $Template::Liquid::Utility::TagEnd = qr[\s*-?%}]o;
12             $Template::Liquid::Utility::VariableSignature = qr{\(?[\w\-\.\[\]]\)?}o;
13             my $VariableSegment = qr[[\w\-]\??]ox;
14             $Template::Liquid::Utility::VariableStart = qr[\{\{\s*]o;
15             $Template::Liquid::Utility::VariableEnd = qr[\s*}}]o;
16             my $VariableIncompleteEnd = qr[}}?];
17             my $QuotedString = qr/"(?:[^"\\]|\\.)*"|'(?:[^'\\]|\\.)*'/o;
18             my $QuotedFragment = qr/${QuotedString}|(?:[^\s,\|'"]|${QuotedString})+/o;
19             my $StrictQuotedFragment = qr/"[^"]+"|'[^']+'|[^\s,\|,\:,\,]+/o;
20             my $FirstFilterArgument
21             = qr/${Template::Liquid::Utility::FilterArgumentSeparator}(?:${StrictQuotedFragment})/o;
22             my $OtherFilterArgument
23             = qr/${ArgumentSeparator}(?:${StrictQuotedFragment})/o;
24             my $SpacelessFilter
25             = qr/${Template::Liquid::Utility::FilterSeparator}(?:${StrictQuotedFragment})(?:${FirstFilterArgument}(?:${OtherFilterArgument})*)?/o;
26             $Template::Liquid::Utility::Expression = qr/(?:${QuotedFragment}(?:${SpacelessFilter})*)/o;
27             $Template::Liquid::Utility::TagAttributes = qr[(\w+)(?:\s*\:\s*(${QuotedFragment}))?]o;
28             my $AnyStartingTag = qr[\{\{|\{\%]o;
29             my $PartialTemplateParser
30             = qr[${Template::Liquid::Utility::TagStart}.*?${Template::Liquid::Utility::TagEnd}|${Template::Liquid::Utility::VariableStart}.*?${VariableIncompleteEnd}]so;
31             my $TemplateParser = qr[(${PartialTemplateParser}|${AnyStartingTag})]o;
32             $Template::Liquid::Utility::VariableParser = qr[^
33             ${Template::Liquid::Utility::VariableStart} # {{
34             ([\w\.]+) # name
35             (?:\s*\|\s*(.+)\s*)? # filters
36             ${Template::Liquid::Utility::VariableEnd} # }}
37             $]ox;
38             $Template::Liquid::Utility::VariableFilterArgumentParser
39             = qr[\s*,\s*(?=(?:[^\']*\'[^\']*\')*(?![^\']*\'))]o;
40             $Template::Liquid::Utility::TagMatch = qr[^${Template::Liquid::Utility::TagStart} # {%
41             (.+?) # etc
42             ${Template::Liquid::Utility::TagEnd} # %}
43             $]sox;
44             $Template::Liquid::Utility::VarMatch = qr[^
45             ${Template::Liquid::Utility::VariableStart} # {{
46             (.+?) # stuff + filters?
47             ${Template::Liquid::Utility::VariableEnd} # }}
48             $]sox;
49             no warnings 'redefine';
50 3     3   22 map { $_ ? $_ : () } split $TemplateParser, shift || '';
  3         6  
  3         276  
51             }
52 2 100 50 2 0 1445 1;
  54         90  
53              
54             =pod
55              
56             =encoding UTF-8
57              
58             =head1 NAME
59              
60             Template::Liquid::Utility - Utility stuff. Watch your step.
61              
62             =head1 Description
63              
64             It's best to just forget this package exists. It's messy but seems to work.
65              
66             =head1 See Also
67              
68             Liquid for Designers: http://wiki.github.com/tobi/liquid/liquid-for-designers
69              
70             L<Template::Liquid|Template::Liquid/"Create your own filters">'s docs on
71             custom filter creation
72              
73             =head1 Author
74              
75             Sanko Robinson <sanko@cpan.org> - http://sankorobinson.com/
76              
77             The original Liquid template system was developed by jadedPixel
78             (http://jadedpixel.com/) and Tobias Lütke (http://blog.leetsoft.com/).
79              
80             =head1 License and Legal
81              
82             Copyright (C) 2009-2012 by Sanko Robinson E<lt>sanko@cpan.orgE<gt>
83              
84             This program is free software; you can redistribute it and/or modify it under
85             the terms of The Artistic License 2.0. See the F<LICENSE> file included with
86             this distribution or http://www.perlfoundation.org/artistic_license_2_0. For
87             clarification, see http://www.perlfoundation.org/artistic_2_0_notes.
88              
89             When separated from the distribution, all original POD documentation is
90             covered by the Creative Commons Attribution-Share Alike 3.0 License. See
91             http://creativecommons.org/licenses/by-sa/3.0/us/legalcode. For
92             clarification, see http://creativecommons.org/licenses/by-sa/3.0/us/.
93              
94             =cut