| 1 | package Template::LiquidX::Tidy::Liquid::Utility; | ||||||||||||||||||||
| 2 | 3 | ▶ | use strict; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 3 | 3 | ▶ | use warnings; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 4 | 3 | ▶ | use Template::Liquid::Utility; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 5 | |||||||||||||||||||||
| 6 | 3 | our $VERSION = '1.0.10'; | |||||||||||||||||||
| 7 | 3 | $Template::Liquid::Utility::FilterSeparator = qr[\s*\|\s*]o; | |||||||||||||||||||
| 8 | 3 | my $ArgumentSeparator = qr[,]o; | |||||||||||||||||||
| 9 | 3 | $Template::Liquid::Utility::FilterArgumentSeparator = qr[\s*:\s*]o; | |||||||||||||||||||
| 10 | 3 | $Template::Liquid::Utility::VariableAttributeSeparator = qr[\.]o; | |||||||||||||||||||
| 11 | 3 | $Template::Liquid::Utility::TagStart = qr[{%-?\s*]o; | |||||||||||||||||||
| 12 | 3 | $Template::Liquid::Utility::TagEnd = qr[\s*-?%}]o; | |||||||||||||||||||
| 13 | 3 | $Template::Liquid::Utility::VariableSignature = qr{\(?[\w\-\.\[\]]\)?}o; | |||||||||||||||||||
| 14 | 3 | my $VariableSegment = qr[[\w\-]\??]ox; | |||||||||||||||||||
| 15 | 3 | $Template::Liquid::Utility::VariableStart = qr[\{\{\s*]o; | |||||||||||||||||||
| 16 | 3 | $Template::Liquid::Utility::VariableEnd = qr[\s*}}]o; | |||||||||||||||||||
| 17 | 3 | my $VariableIncompleteEnd = qr[}}?]; | |||||||||||||||||||
| 18 | 3 | my $QuotedString = qr/"(?:[^"\\]|\\.)*"|'(?:[^'\\]|\\.)*'/o; | |||||||||||||||||||
| 19 | 3 | my $QuotedFragment = qr/${QuotedString}|(?:[^\s,\|'"]|${QuotedString})+/o; | |||||||||||||||||||
| 20 | 3 | my $StrictQuotedFragment = qr/"[^"]+"|'[^']+'|[^\s,\|,\:,\,]+/o; | |||||||||||||||||||
| 21 | 3 | my $FirstFilterArgument | |||||||||||||||||||
| 22 | = qr/${Template::Liquid::Utility::FilterArgumentSeparator}(?:${StrictQuotedFragment})/o; | ||||||||||||||||||||
| 23 | 3 | my $OtherFilterArgument | |||||||||||||||||||
| 24 | = qr/${ArgumentSeparator}(?:${StrictQuotedFragment})/o; | ||||||||||||||||||||
| 25 | 3 | my $SpacelessFilter | |||||||||||||||||||
| 26 | = qr/${Template::Liquid::Utility::FilterSeparator}(?:${StrictQuotedFragment})(?:${FirstFilterArgument}(?:${OtherFilterArgument})*)?/o; | ||||||||||||||||||||
| 27 | 3 | $Template::Liquid::Utility::Expression = qr/(?:${QuotedFragment}(?:${SpacelessFilter})*)/o; | |||||||||||||||||||
| 28 | 3 | $Template::Liquid::Utility::TagAttributes = qr[(\w+)(?:\s*\:\s*(${QuotedFragment}))?]o; | |||||||||||||||||||
| 29 | 3 | my $AnyStartingTag = qr[\{\{|\{\%]o; | |||||||||||||||||||
| 30 | 3 | my $PartialTemplateParser | |||||||||||||||||||
| 31 | = qr[${Template::Liquid::Utility::TagStart}.*?${Template::Liquid::Utility::TagEnd}|${Template::Liquid::Utility::VariableStart}.*?${VariableIncompleteEnd}]so; | ||||||||||||||||||||
| 32 | 3 | my $TemplateParser = qr[(${PartialTemplateParser}|${AnyStartingTag})]o; | |||||||||||||||||||
| 33 | 3 | $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 | 3 | $Template::Liquid::Utility::VariableFilterArgumentParser | |||||||||||||||||||
| 40 | = qr[\s*,\s*(?=(?:[^\']*\'[^\']*\')*(?![^\']*\'))]o; | ||||||||||||||||||||
| 41 | 3 | $Template::Liquid::Utility::TagMatch = qr[^${Template::Liquid::Utility::TagStart} # {% | |||||||||||||||||||
| 42 | (.+?) # etc | ||||||||||||||||||||
| 43 | ${Template::Liquid::Utility::TagEnd} # %} | ||||||||||||||||||||
| 44 | $]sox; | ||||||||||||||||||||
| 45 | 3 | $Template::Liquid::Utility::VarMatch = qr[^ | |||||||||||||||||||
| 46 | ${Template::Liquid::Utility::VariableStart} # {{ | ||||||||||||||||||||
| 47 | (.+?) # stuff + filters? | ||||||||||||||||||||
| 48 | ${Template::Liquid::Utility::VariableEnd} # }} | ||||||||||||||||||||
| 49 | $]sox; | ||||||||||||||||||||
| 50 | 3 | ▶ | no warnings 'redefine'; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 51 | sub Template::Liquid::Utility::tokenize { | ||||||||||||||||||||
| 52 | 2 | ▶ | map { $_ ? $_ : () } split $TemplateParser, shift || ''; | ||||||||||||||||||
|
Subroutine
tokenize: called CC=3 SCAR=11.1
Pod
undocumented
Branch: 1 branch
Condition50%1/2
shift() || ''
MC/DC0%0/1
shift() || ''
shift()
Truth table50%1/2
A
A= shift()
| |||||||||||||||||||||
| 53 | } | ||||||||||||||||||||
| 54 | 3 | 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<Template::Liquid|Template::Liquid/"Create your own filters">'s docs on | ||||||||||||||||||||
| 73 | custom filter creation | ||||||||||||||||||||
| 74 | |||||||||||||||||||||
| 75 | =head1 Author | ||||||||||||||||||||
| 76 | |||||||||||||||||||||
| 77 | Sanko Robinson <sanko@cpan.org> - 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 E<lt>sanko@cpan.orgE<gt> | ||||||||||||||||||||
| 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<LICENSE> 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 | ||||||||||||||||||||