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