TT2/Emitter.pm

filter: Statementstmt 64.8% 177 / 273 Branchbran 55.5% 60 / 108 Conditioncond 50.0% 4 / 8 MC/DCmcdc 0.0% 0 / 5 Subroutinesub 65.3% 17 / 26 Podpod 0.0% 0 / 2 totaltotal 61.1% 258 / 422 CC 73 SCAR 30.7
CC
73
Cov
62%
_emit_expr
46.7
_emit_filter_single
42.0
_emit_filter_application
14.5
CRAP 21.6
« TT2/Parser.pm ↑ Summary TT2/Tokenizer.pm »
1 package Jinja2::TT2::Emitter;
2  
3 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶use v5.20;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 1 ▶use Jinja2::TT2::Filters;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 1 ▶sub new {
Subroutine new: called CC=2 SCAR=7.2
Pod undocumented
10 1 my ($class, %opts) = @_;
11 return bless {
12 indent_level => 0,
13 1 ▶ indent_str => $opts{indent_str} // ' ',
Condition50%1/2
$opts{"indent_str"} // " "
l!l
01
MC/DC0%0/1
$opts{"indent_str"} // " "
$opts{"indent_str"}
Truth table50%1/2
A
A= $opts{"indent_str"}
Aresult
11
00
14 filters => Jinja2::TT2::Filters->new(),
15 }, $class;
16 }
17  
18 112 ▶sub emit {
Subroutine emit: called CC=3 SCAR=11.1
Pod undocumented
19 112 my ($self, $ast) = @_;
20  
21 112 ▶ if ($ast->{type} eq 'ROOT') {
Branch: 1 branch
BranchTrueFalseTotal
if ($ast->{"type"} eq "ROOT") 43 69 112
22 43 return join('', map { $self->emit($_) } @{$ast->{body}});
23 }
24  
25 69 my $method = '_emit_' . lc($ast->{type});
26 69 ▶ if ($self->can($method)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->can($method)) 69 0 69
27 69 return $self->$method($ast);
28 }
29  
30 0 die "Unknown AST node type: $ast->{type}";
31 }
32  
33 19 ▶sub _emit_text {
Subroutine _emit_text: called CC=1 SCAR=0.0
34 19 my ($self, $node) = @_;
35 19 return $node->{value};
36 }
37  
38 1 ▶sub _emit_comment {
Subroutine _emit_comment: called CC=1 SCAR=0.0
39 1 my ($self, $node) = @_;
40 1 return "[%# $node->{value} %]";
41 }
42  
43 32 ▶sub _emit_output {
Subroutine _emit_output: called CC=3 SCAR=11.0
44 32 my ($self, $node) = @_;
45  
46 32 ▶ my $strip_before = $node->{strip_before} ? '-' : '';
Branch: 1 branch
BranchTrueFalseTotal
$node->{'strip_before'} ? : 1 31 32
47 32 ▶ my $strip_after = $node->{strip_after} ? '-' : '';
Branch: 1 branch
BranchTrueFalseTotal
$node->{'strip_after'} ? : 1 31 32
48  
49 32 my $expr = $self->_emit_expr($node->{expr});
50 32 return "[%$strip_before $expr $strip_after%]";
51 }
52  
53 10 ▶sub _emit_if {
Subroutine _emit_if: called CC=9 SCAR=22.1
54 10 my ($self, $node) = @_;
55  
56 10 ▶ my $strip_before = $node->{strip_before} ? '-' : '';
Branch: 1 branch
BranchTrueFalseTotal
$node->{'strip_before'} ? : 0 10 10
57 10 ▶ my $strip_after = $node->{strip_after} ? '-' : '';
Branch: 1 branch
BranchTrueFalseTotal
$node->{'strip_after'} ? : 0 10 10
58  
59 10 my $condition = $self->_emit_expr($node->{condition});
60 10 my $output = "[%$strip_before IF $condition $strip_after%]";
61  
62 10 for my $child (@{$node->{body}}) {
63 6 $output .= $self->emit($child);
64 }
65  
66 10 for my $branch (@{$node->{branches}}) {
67 4 ▶ if ($branch->{type} eq 'ELIF') {
Branch: 2 branches
BranchTrueFalseTotal
if ($branch->{'type'} eq 'ELIF') { } 1 3 4
elsif ($branch->{'type'} eq 'ELSE') { } 3 0 3
68 1 my $elif_cond = $self->_emit_expr($branch->{condition});
69 1 $output .= "[% ELSIF $elif_cond %]";
70 1 for my $child (@{$branch->{body}}) {
71 1 $output .= $self->emit($child);
72 }
73 } elsif ($branch->{type} eq 'ELSE') {
74 3 $output .= "[% ELSE %]";
75 3 for my $child (@{$branch->{body}}) {
76 3 $output .= $self->emit($child);
77 }
78 }
79 }
80  
81 10 $output .= "[% END %]";
82 10 return $output;
83 }
84  
85 3 ▶sub _emit_for {
Subroutine _emit_for: called CC=5 SCAR=17.6
86 3 my ($self, $node) = @_;
87  
88 3 my $loop_var = join(', ', @{$node->{loop_vars}});
89 3 my $iterable = $self->_emit_expr($node->{iterable});
90  
91 3 my $output = "[% FOREACH $loop_var IN $iterable %]";
92  
93 3 for my $child (@{$node->{body}}) {
94 7 $output .= $self->emit($child);
95 }
96  
97 # Handle else clause (TT2 doesn't have for/else, need WRAPPER or conditional)
98 3 ▶ if (@{$node->{else_body}}) {
Branch: 1 branch
BranchTrueFalseTotal
if (@{$node->{"else_body"};}) 0 3 3
99 # TT2 workaround: use IF for empty check
100 0 $output = "[% IF $iterable.size %]" . $output . "[% ELSE %]";
101 0 for my $child (@{$node->{else_body}}) {
102 0 $output .= $self->emit($child);
103 }
104 0 $output .= "[% END %]";
105 }
106  
107 3 ▶ $output .= "[% END %]" unless @{$node->{else_body}};
Branch: 1 branch
BranchTrueFalseTotal
unless @{$node->{"else_body"};} 3 0 3
108  
109 3 return $output;
110 }
111  
112 1 ▶sub _emit_block {
Subroutine _emit_block: called CC=2 SCAR=6.9
113 1 my ($self, $node) = @_;
114  
115 1 my $output = "[% BLOCK $node->{name} %]";
116  
117 1 for my $child (@{$node->{body}}) {
118 1 $output .= $self->emit($child);
119 }
120  
121 1 $output .= "[% END %]";
122 1 return $output;
123 }
124  
125 0 ▶sub _emit_extends {
Subroutine _emit_extends: not called CC=1 SCAR=6.9
126 0 my ($self, $node) = @_;
127  
128 0 my $template = $self->_emit_expr($node->{template});
129 # Remove quotes for TT2 PROCESS/WRAPPER
130 0 $template =~ s/^['"]|['"]$//g;
131  
132 # TT2 doesn't have direct extends; use WRAPPER or PROCESS
133 # For now, emit as a comment + PROCESS
134 0 return "[%# EXTENDS: $template - use WRAPPER in TT2 %]\n[% PROCESS $template %]";
135 }
136  
137 1 ▶sub _emit_include {
Subroutine _emit_include: called CC=3 SCAR=11.2
138 1 my ($self, $node) = @_;
139  
140 1 ▶ my $strip_before = $node->{strip_before} ? '-' : '';
Branch: 1 branch
BranchTrueFalseTotal
$node->{'strip_before'} ? : 0 1 1
141 1 ▶ my $strip_after = $node->{strip_after} ? '-' : '';
Branch: 1 branch
BranchTrueFalseTotal
$node->{'strip_after'} ? : 0 1 1
142  
143 1 my $template = $self->_emit_expr($node->{template});
144 1 $template =~ s/^['"]|['"]$//g;
145  
146 1 return "[%$strip_before INCLUDE $template $strip_after%]";
147 }
148  
149 0 ▶sub _emit_import {
Subroutine _emit_import: not called CC=1 SCAR=6.9
150 0 my ($self, $node) = @_;
151  
152 0 my $template = $self->_emit_expr($node->{template});
153 0 $template =~ s/^['"]|['"]$//g;
154  
155 # TT2 uses PROCESS for imports; macros become available
156 0 return "[%# IMPORT $template AS $node->{alias} %]\n[% USE $node->{alias} = $template %]";
157 }
158  
159 0 ▶sub _emit_from {
Subroutine _emit_from: not called CC=2 SCAR=17.9
160 0 my ($self, $node) = @_;
161  
162 0 my $template = $self->_emit_expr($node->{template});
163 0 $template =~ s/^['"]|['"]$//g;
164  
165 0 ▶ my @imports = map { $_->{name} . ($_->{alias} ne $_->{name} ? " AS $_->{alias}" : '') }
Branch: 1 branch
BranchTrueFalseTotal
$_->{'alias'} ne $_->{'name'} ? : 0 0 0
166 0 @{$node->{imports}};
167  
168 0 return "[%# FROM $template IMPORT " . join(', ', @imports) . " %]";
169 }
170  
171 1 ▶sub _emit_set {
Subroutine _emit_set: called CC=3 SCAR=14.2
172 1 my ($self, $node) = @_;
173  
174 1 my $names = join(', ', @{$node->{names}});
175  
176 1 ▶ if ($node->{value}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($node->{'value'}) { } 1 0 1
177 # Inline set
178 1 my $value = $self->_emit_expr($node->{value});
179 1 return "[% $names = $value %]";
180 } else {
181 # Block set - use FILTER to capture content
182 0 my $output = "[% FILTER \$set_$names %]";
183 0 for my $child (@{$node->{body}}) {
184 0 $output .= $self->emit($child);
185 }
186 0 $output .= "[% END %][% $names = set_$names %]";
187 0 return $output;
188 }
189 }
190  
191 1 ▶sub _emit_macro {
Subroutine _emit_macro: called CC=3 SCAR=11.1
192 1 my ($self, $node) = @_;
193  
194 my @args = map {
195 1 my $arg = $_->{name};
196 1 ▶ if (defined $_->{default}) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $_->{"default"}) 0 1 1
197 0 $arg .= " = " . $self->_emit_expr($_->{default});
198 }
199 1 $arg;
200 1 } @{$node->{args}};
201  
202 1 my $output = "[% MACRO $node->{name}(" . join(', ', @args) . ") BLOCK %]";
203  
204 1 for my $child (@{$node->{body}}) {
205 2 $output .= $self->emit($child);
206 }
207  
208 1 $output .= "[% END %]";
209 1 return $output;
210 }
211  
212 0 ▶sub _emit_call {
Subroutine _emit_call: not called CC=2 SCAR=17.9
213 0 my ($self, $node) = @_;
214  
215 0 my $call = $self->_emit_expr($node->{call});
216  
217 # TT2 doesn't have direct call blocks; emit as WRAPPER
218 0 my $output = "[%# CALL $call %]\n[% WRAPPER $call %]";
219  
220 0 for my $child (@{$node->{body}}) {
221 0 $output .= $self->emit($child);
222 }
223  
224 0 $output .= "[% END %]";
225 0 return $output;
226 }
227  
228 0 ▶sub _emit_filter {
Subroutine _emit_filter: not called CC=2 SCAR=17.9
229 0 my ($self, $node) = @_;
230  
231 0 my $filter = $self->_emit_filter_single($node->{filter});
232  
233 0 my $output = "[% FILTER $filter %]";
234  
235 0 for my $child (@{$node->{body}}) {
236 0 $output .= $self->emit($child);
237 }
238  
239 0 $output .= "[% END %]";
240 0 return $output;
241 }
242  
243 0 ▶sub _emit_raw {
Subroutine _emit_raw: not called CC=1 SCAR=6.9
244 0 my ($self, $node) = @_;
245 # TT2 has no raw tag; content is already literal
246 # Could use [% RAWPERL %] but that's different
247 0 return $node->{value};
248 }
249  
250 0 ▶sub _emit_with {
Subroutine _emit_with: not called CC=3 SCAR=24.8
251 0 my ($self, $node) = @_;
252  
253 # TT2 doesn't have 'with'; simulate with SET in a wrapper
254 0 my $output = "[%# WITH scope %]";
255  
256 0 for my $assign (@{$node->{assignments}}) {
257 0 $output .= "[% SET $assign->{name} = " . $self->_emit_expr($assign->{value}) . " %]";
258 }
259  
260 0 for my $child (@{$node->{body}}) {
261 0 $output .= $self->emit($child);
262 }
263  
264 0 return $output;
265 }
266  
267 0 ▶sub _emit_autoescape {
Subroutine _emit_autoescape: not called CC=2 SCAR=17.9
268 0 my ($self, $node) = @_;
269  
270 # TT2 handles escaping differently; emit as comment
271 0 my $output = "[%# AUTOESCAPE " . $self->_emit_expr($node->{enabled}) . " %]";
272  
273 0 for my $child (@{$node->{body}}) {
274 0 $output .= $self->emit($child);
275 }
276  
277 0 $output .= "[%# END AUTOESCAPE %]";
278 0 return $output;
279 }
280  
281 # Expression emitters
282 91 ▶sub _emit_expr {
Subroutine _emit_expr: called CC=32 SCAR=38.4
283 91 my ($self, $node) = @_;
284  
285 91 ▶ return '' unless $node;
Branch: 1 branch
BranchTrueFalseTotal
unless $node 0 91 91
286  
287 91 my $type = $node->{type};
288  
289 91 ▶ if ($type eq 'NAME') {
Branch: 1 branch
BranchTrueFalseTotal
if ($type eq "NAME") 48 43 91
290 48 my $name = $node->{value};
291 # Map Jinja2 loop variables to TT2
292 48 ▶ if ($name eq 'loop') {
Branch: 1 branch
BranchTrueFalseTotal
if ($name eq "loop") 5 43 48
293 5 return 'loop';
294 }
295 43 return $name;
296 }
297  
298 43 ▶ if ($type eq 'LITERAL') {
Branch: 1 branch
BranchTrueFalseTotal
if ($type eq "LITERAL") 14 29 43
299 14 ▶ if ($node->{subtype} eq 'STRING') {
Branch: 3 branches
BranchTrueFalseTotal
if ($node->{'subtype'} eq 'STRING') { } 3 11 14
elsif ($node->{'subtype'} eq 'BOOL') { } 4 7 11
elsif ($node->{'subtype'} eq 'NONE') { } 0 7 7
300 3 my $val = $node->{value};
301 3 $val =~ s/'/\\'/g;
302 3 return "'$val'";
303 } elsif ($node->{subtype} eq 'BOOL') {
304 4 ▶ return $node->{value} ? '1' : '0';
Branch: 1 branch
BranchTrueFalseTotal
$node->{'value'} ? : 2 2 4
305 } elsif ($node->{subtype} eq 'NONE') {
306 0 return 'undef';
307 } else {
308 7 return $node->{value};
309 }
310 }
311  
312 29 ▶ if ($type eq 'BINOP') {
Branch: 1 branch
BranchTrueFalseTotal
if ($type eq "BINOP") 6 23 29
313 6 my $left = $self->_emit_expr($node->{left});
314 6 my $right = $self->_emit_expr($node->{right});
315 6 my $op = $node->{op};
316  
317 # Map operators
318 6 my %op_map = (
319 'and' => 'AND',
320 'or' => 'OR',
321 '~' => '_', # String concatenation
322 'in' => 'IN',
323 'not in' => 'NOT IN',
324 '==' => '==',
325 '!=' => '!=',
326 '//' => 'div', # Integer division
327 );
328  
329 6 ▶ $op = $op_map{$op} // $op;
Condition66%2/3
$op_map{$op} // $op
l!l&&r!l&&!r
510
MC/DC0%0/2
$op_map{$op} // $op
$op_map{$op} $op
Truth table66%2/3
A // B
A= $op_map{$op}B= $op
ABresult
1X1
011
000
330  
331 6 return "($left $op $right)";
332 }
333  
334 23 ▶ if ($type eq 'UNARYOP') {
Branch: 1 branch
BranchTrueFalseTotal
if ($type eq "UNARYOP") 1 22 23
335 1 my $operand = $self->_emit_expr($node->{operand});
336 1 my $op = $node->{op};
337  
338 1 ▶ if ($op eq 'not') {
Branch: 1 branch
BranchTrueFalseTotal
if ($op eq "not") 1 0 1
339 1 return "NOT $operand";
340 }
341  
342 0 return "$op$operand";
343 }
344  
345 22 ▶ if ($type eq 'TERNARY') {
Branch: 1 branch
BranchTrueFalseTotal
if ($type eq "TERNARY") 1 21 22
346 1 my $true_val = $self->_emit_expr($node->{true_val});
347 1 my $condition = $self->_emit_expr($node->{condition});
348 1 ▶ my $false_val = $node->{false_val} ? $self->_emit_expr($node->{false_val}) : "''";
Branch: 1 branch
BranchTrueFalseTotal
$node->{'false_val'} ? : 1 0 1
349  
350 1 return "($condition ? $true_val : $false_val)";
351 }
352  
353 21 ▶ if ($type eq 'GETATTR') {
Branch: 1 branch
BranchTrueFalseTotal
if ($type eq "GETATTR") 7 14 21
354 7 my $expr = $self->_emit_expr($node->{expr});
355 7 my $attr = $node->{attr};
356  
357 # Map loop attributes
358 7 ▶ if ($expr eq 'loop') {
Branch: 1 branch
BranchTrueFalseTotal
if ($expr eq "loop") 5 2 7
359 5 my %loop_map = (
360 'index' => 'count',
361 'index0' => 'index',
362 'revindex' => 'max - loop.index + 1',
363 'first' => 'first',
364 'last' => 'last',
365 'length' => 'size',
366 'cycle' => 'cycle',
367 );
368 5 ▶ return 'loop.' . ($loop_map{$attr} // $attr);
Condition33%1/3
$loop_map{$attr} // $attr
l!l&&r!l&&!r
500
MC/DC0%0/2
$loop_map{$attr} // $attr
$loop_map{$attr} $attr
Truth table33%1/3
A // B
A= $loop_map{$attr}B= $attr
ABresult
1X1
011
000
369 }
370  
371 2 return "$expr.$attr";
372 }
373  
374 14 ▶ if ($type eq 'GETITEM') {
Branch: 1 branch
BranchTrueFalseTotal
if ($type eq "GETITEM") 1 13 14
375 1 my $expr = $self->_emit_expr($node->{expr});
376 1 my $index = $self->_emit_expr($node->{index});
377  
378 1 ▶ return "$expr.\$index" if $index =~ /^[a-zA-Z]/;
Branch: 1 branch
BranchTrueFalseTotal
if $index =~ /^[a-zA-Z]/u 0 1 1
379 1 return "$expr.$index";
380 }
381  
382 13 ▶ if ($type eq 'CALL') {
Branch: 1 branch
BranchTrueFalseTotal
if ($type eq "CALL") 1 12 13
383 1 my $expr = $self->_emit_expr($node->{expr});
384 1 my @args = map { $self->_emit_expr($_) } @{$node->{args}};
385  
386 1 for my $kwarg (@{$node->{kwargs}}) {
387 0 push @args, "$kwarg->{name} = " . $self->_emit_expr($kwarg->{value});
388 }
389  
390 # Handle built-in functions
391 1 ▶ if ($expr eq 'range') {
Branch: 1 branch
BranchTrueFalseTotal
if ($expr eq "range") 1 0 1
392 1 ▶ if (@args == 1) {
Branch: 3 branches
BranchTrueFalseTotal
if (@args == 1) { } 1 0 1
elsif (@args == 2) { } 0 0 0
elsif (@args == 3) { } 0 0 0
393 1 return "[0 .. $args[0] - 1]";
394 } elsif (@args == 2) {
395 0 return "[$args[0] .. $args[1] - 1]";
396 } elsif (@args == 3) {
397 # range with step - complex in TT2
398 0 return "[% # range($args[0], $args[1], $args[2]) %]";
399 }
400 }
401  
402 0 ▶ if ($expr eq 'super') {
Branch: 1 branch
BranchTrueFalseTotal
if ($expr eq "super") 0 0 0
403 0 return 'content'; # TT2's WRAPPER content
404 }
405  
406 0 return "$expr(" . join(', ', @args) . ")";
407 }
408  
409 12 ▶ if ($type eq 'FILTER') {
Branch: 1 branch
BranchTrueFalseTotal
if ($type eq "FILTER") 10 2 12
410 10 my $base = $self->_emit_expr($node->{expr});
411 10 return $self->_emit_filter_application($base, $node);
412 }
413  
414 2 ▶ if ($type eq 'LIST') {
Branch: 1 branch
BranchTrueFalseTotal
if ($type eq "LIST") 1 1 2
415 1 my @elements = map { $self->_emit_expr($_) } @{$node->{elements}};
416 1 return '[' . join(', ', @elements) . ']';
417 }
418  
419 1 ▶ if ($type eq 'TUPLE') {
Branch: 1 branch
BranchTrueFalseTotal
if ($type eq "TUPLE") 0 1 1
420 0 my @elements = map { $self->_emit_expr($_) } @{$node->{elements}};
421 0 return '[' . join(', ', @elements) . ']'; # TT2 uses arrays
422 }
423  
424 1 ▶ if ($type eq 'DICT') {
Branch: 1 branch
BranchTrueFalseTotal
if ($type eq "DICT") 1 0 1
425 my @pairs = map {
426 1 my $key = $self->_emit_expr($_->{key});
427 1 my $val = $self->_emit_expr($_->{value});
428 1 "$key => $val";
429 1 } @{$node->{pairs}};
430 1 return '{ ' . join(', ', @pairs) . ' }';
431 }
432  
433 0 ▶ if ($type eq 'NAMED_ARG') {
Branch: 1 branch
BranchTrueFalseTotal
if ($type eq "NAMED_ARG") 0 0 0
434 0 my $value = $self->_emit_expr($node->{value});
435 0 return "$node->{name} = $value";
436 }
437  
438 0 die "Unknown expression type: $type";
439 }
440  
441 10 ▶sub _emit_filter_application {
Subroutine _emit_filter_application: called CC=7 SCAR=26.8
442 10 my ($self, $base, $node) = @_;
443  
444 10 my $filter_name = $node->{name};
445 10 my @args = map { $self->_emit_expr($_) } @{$node->{args}};
446  
447 # Get the TT2 equivalent
448 10 my $tt2_filter = $self->{filters}->map_filter($filter_name, \@args);
449  
450 10 ▶ if ($tt2_filter->{type} eq 'vmethod') {
Branch: 3 branches
BranchTrueFalseTotal
if ($tt2_filter->{'type'} eq 'vmethod') { } 10 0 10
elsif ($tt2_filter->{'type'} eq 'filter') { } 0 0 0
elsif ($tt2_filter->{'type'} eq 'custom') { } 0 0 0
451 10 ▶ if ($tt2_filter->{args}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($tt2_filter->{'args'}) { } 1 9 10
452 1 return "$base.$tt2_filter->{name}($tt2_filter->{args})";
453 } else {
454 9 return "$base.$tt2_filter->{name}";
455 }
456 } elsif ($tt2_filter->{type} eq 'filter') {
457 0 ▶ if ($tt2_filter->{args}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($tt2_filter->{'args'}) { } 0 0 0
458 0 return "$base | $tt2_filter->{name}($tt2_filter->{args})";
459 } else {
460 0 return "$base | $tt2_filter->{name}";
461 }
462 } elsif ($tt2_filter->{type} eq 'custom') {
463 0 return $tt2_filter->{code}->($base, @args);
464 } else {
465 # Passthrough - keep original name
466 0 ▶ my $args_str = @args ? '(' . join(', ', @args) . ')' : '';
Branch: 1 branch
BranchTrueFalseTotal
@args ? : 0 0 0
467 0 return "$base | $filter_name$args_str";
468 }
469 }
470  
471 0 ▶sub _emit_filter_single {
Subroutine _emit_filter_single: not called CC=6 SCAR=37.4
472 0 my ($self, $node) = @_;
473  
474 0 ▶ if ($node->{type} eq 'FILTER') {
Branch: 2 branches
BranchTrueFalseTotal
if ($node->{'type'} eq 'FILTER') { } 0 0 0
elsif ($node->{'type'} eq 'NAME') { } 0 0 0
475 0 ▶ my $inner = $node->{expr} ? $self->_emit_filter_single($node->{expr}) : '';
Branch: 1 branch
BranchTrueFalseTotal
$node->{'expr'} ? : 0 0 0
476 0 my $filter_name = $node->{name};
477 0 my @args = map { $self->_emit_expr($_) } @{$node->{args}};
478  
479 0 ▶ my $args_str = @args ? '(' . join(', ', @args) . ')' : '';
Branch: 1 branch
BranchTrueFalseTotal
@args ? : 0 0 0
480 0 my $this_filter = "$filter_name$args_str";
481  
482 0 ▶ return $inner ? "$inner | $this_filter" : $this_filter;
Branch: 1 branch
BranchTrueFalseTotal
$inner ? : 0 0 0
483 } elsif ($node->{type} eq 'NAME') {
484 0 return $node->{value};
485 }
486  
487 0 die "Unexpected filter node type: $node->{type}";
488 }
489  
490 1 1;
491  
492 __END__
« TT2/Parser.pm ↑ Summary TT2/Tokenizer.pm »