Liquid/Tag/Raw.pm

filter: Statementstmt 96.7% 30 / 31 Branchbran 58.3% 7 / 12 Conditioncond 66.6% 4 / 6 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 100% 7 / 7 Podpod 0.0% 0 / 2 totaltotal 77.4% 48 / 62 CC 10 SCAR 17.1
CC
10
Cov
84%
_dump_nodes
9.3
new
3.1
BEGIN
1.0
CRAP 5.5
« Liquid/Tag/Case.pm ↑ Summary Liquid/Variable.pm »
1 package Template::Liquid::Tag::Raw;
2 25 our $VERSION = '1.0.23';
3 25 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 25 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 25 require Template::Liquid::Error;
6 25 ▶use base 'Template::Liquid::Tag';
Subroutine BEGIN: called CC=1 SCAR=0.0
7 25 ▶sub import { Template::Liquid::register_tag('raw') }
Subroutine import: called CC=1 SCAR=0.0
8  
9 3 ▶sub new {
Subroutine new: called CC=3 SCAR=11.3
Pod undocumented
10 3 my ($class, $args) = @_;
11 raise Template::Liquid::Error {type => 'Context',
12 template => $args->{template},
13 message => 'Missing template argument',
14 fatal => 1
15 }
16 3 ▶ if !defined $args->{'template'};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $args->{"template"} 0 3 3
17 raise Template::Liquid::Error {type => 'Context',
18 template => $args->{template},
19 message => 'Missing parent argument',
20 fatal => 1
21 }
22 3 ▶ if !defined $args->{'parent'};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $args->{"parent"} 0 3 3
23 my $s = bless {name => '?-' . int rand(time),
24 blocks => [],
25 tag_name => $args->{'tag_name'},
26 template => $args->{'template'},
27 parent => $args->{'parent'},
28 markup => $args->{'markup'},
29 3 end_tag => 'end' . $args->{'tag_name'}
30 }, $class;
31 3 return $s;
32 }
33  
34 3 ▶sub render {
Subroutine render: called CC=1 SCAR=0.0
Pod undocumented
35 3 my ($s) = @_;
36 3 my $var = $s->{'variable_name'};
37 3 my $val = '';
38 3 return _dump_nodes(@{$s->{'nodelist'}});
39 }
40  
41 3 ▶sub _dump_nodes {
Subroutine _dump_nodes: called CC=8 SCAR=22.3
42 3 my $ret = '';
43 3 for my $node (@_) {
44 9 ▶ my $rendering = ref $node ? $node->{'markup'} : $node;
Branch: 1 branch
BranchTrueFalseTotal
ref $node ? : 3 6 9
45 9 ▶ $ret .= defined $rendering ? $rendering : '';
Branch: 1 branch
BranchTrueFalseTotal
defined $rendering ? : 9 0 9
46 0 $ret .= _dump_nodes(@{$node->{'nodelist'}})
47 9 ▶ if ref $node && $node->{'nodelist'};
Branch: 1 branch
BranchTrueFalseTotal
if ref $node and $node->{"nodelist"} 0 9 9
Condition66%2/3
ref $node and $node->{"nodelist"}
!ll&&!rl&&r
630
MC/DC0%0/2
ref $node and $node->{"nodelist"}
ref $node $node->{"nodelist"}
Truth table66%2/3
A and B
A= ref $nodeB= $node->{"nodelist"}
ABresult
0X0
100
111
48 $ret .= ref $node &&
49 9 ▶ defined $node->{'markup_2'} ? $node->{'markup_2'} : '';
Branch: 1 branch
BranchTrueFalseTotal
ref $node && defined $node->{'markup_2'} ? : 0 9 9
Condition66%2/3
ref $node and defined $node->{"markup_2"}
!ll&&!rl&&r
630
MC/DC0%0/2
ref $node and defined $node->{"markup_2"}
ref $node defined $node->{"markup_2"}
Truth table66%2/3
A and B
A= ref $nodeB= defined $node->{"markup_2"}
ABresult
0X0
100
111
50 }
51 3 return $ret;
52 }
53 25 1;
54  
55 =pod
56  
57 =encoding UTF-8
58  
59 =begin stopwords
60  
61 Lütke jadedPixel
62  
63 =end stopwords
64  
65 =head1 NAME
66  
67 Template::Liquid::Tag::Raw - General Purpose Content Container
68  
69 =head1 Synopsis
70  
71 {% raw %}
72 In Handlebars, {{ this }} will be HTML-escaped, but {{{ that }}} will not.
73 {% endraw %}
74  
75 =head1 Description
76  
77 C<raw> is a simple tag. Child nodes are rendered as they appear in the
78 template. Code inside a C<raw> tag is dumped as-is during rendering. So,
79 this...
80  
81 {% raw %}
82 {% for article in articles %}
83 <div class='post' id='{{ article.id }}'>
84 <p class='title'>{{ article.title | capitalize }}</p>
85 {% comment %}
86 Unless we're viewing a single article, we will truncate
87 article.body at 50 words and insert a 'Read more' link.
88 {% endcomment %}
89 ...
90 </div>
91 {% endfor %}
92 {% endraw %}
93  
94 ...would print...
95  
96 {% for article in articles %}
97 <div class='post' id='{{ article.id }}'>
98 <p class='title'>{{ article.title | capitalize }}</p>
99 {% comment %}
100 Unless we're viewing a single article, we will truncate
101 article.body at 50 words and insert a 'Read more' link.
102 {% endcomment %}
103 ...
104 </div>
105 {% endfor %}
106  
107 =head1 See Also
108  
109 Liquid for Designers: http://wiki.github.com/tobi/liquid/liquid-for-designers
110  
111 =head1 Author
112  
113 Sanko Robinson <sanko@cpan.org> - http://sankorobinson.com/
114  
115 The original Liquid template system was developed by jadedPixel
116 (http://jadedpixel.com/) and Tobias Lütke (http://blog.leetsoft.com/).
117  
118 =head1 License and Legal
119  
120 Copyright (C) 2012-2022 by Sanko Robinson E<lt>sanko@cpan.orgE<gt>
121  
122 This program is free software; you can redistribute it and/or modify it under
123 the terms of The Artistic License 2.0. See the F<LICENSE> file included with
124 this distribution or http://www.perlfoundation.org/artistic_license_2_0. For
125 clarification, see http://www.perlfoundation.org/artistic_2_0_notes.
126  
127 When separated from the distribution, all original POD documentation is covered
128 by the Creative Commons Attribution-Share Alike 3.0 License. See
129 http://creativecommons.org/licenses/by-sa/3.0/us/legalcode. For clarification,
130 see http://creativecommons.org/licenses/by-sa/3.0/us/.
131  
132 =cut
« Liquid/Tag/Case.pm ↑ Summary Liquid/Variable.pm »