• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

nette / latte / 29701425453

19 Jul 2026 07:51PM UTC coverage: 94.359% (+0.1%) from 94.22%
29701425453

push

github

dg
{include parent} and {include this} work inside dynamically named blocks

The name of the enclosing block is resolved at runtime from the stack of
blocks being currently rendered, which is shared along the inheritance
chain. Previously this was a compile error, or, when the dynamic block
was nested inside a static one, the include silently bound to the outer
static block.

To be released in 3.1.

20 of 22 new or added lines in 2 files covered. (90.91%)

138 existing lines in 40 files now uncovered.

6273 of 6648 relevant lines covered (94.36%)

0.94 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

96.77
/src/Latte/Compiler/Nodes/Php/ModifierNode.php
1
<?php declare(strict_types=1);
2

3
/**
4
 * This file is part of the Latte (https://latte.nette.org)
5
 * Copyright (c) 2008 David Grudl (https://davidgrudl.com)
6
 */
7

8
namespace Latte\Compiler\Nodes\Php;
9

10
use Latte\Compiler\Node;
11
use Latte\Compiler\Position;
12
use Latte\Compiler\PrintContext;
13
use Latte\Helpers;
14

15

16
/**
17
 * Chain of filters with auto-escape flag.
18
 */
19
class ModifierNode extends Node
20
{
21
        /** @deprecated */
22
        public bool $check = true;
23

24

25
        public function __construct(
1✔
26
                /** @var FilterNode[] */
27
                public array $filters,
28
                public bool $escape = false,
29
                public ?Position $position = null,
30
                public ?Position $end = null,
31
        ) {
32
                (function (FilterNode ...$args) {})(...$filters);
1✔
33
        }
1✔
34

35

36
        public function hasFilter(string $name): bool
1✔
37
        {
38
                foreach ($this->filters as $filter) {
1✔
39
                        if ($filter->name->name === $name) {
1✔
40
                                return true;
1✔
41
                        }
42
                }
43

44
                return false;
1✔
45
        }
46

47

48
        /**
49
         * Removes and returns the first filter with the given name, or null if not found.
50
         */
51
        public function removeFilter(string $name): ?FilterNode
1✔
52
        {
53
                foreach ($this->filters as $i => $filter) {
1✔
54
                        if ($filter->name->name === $name) {
1✔
55
                                return array_splice($this->filters, $i, 1)[0];
1✔
56
                        }
57
                }
58

59
                return null;
1✔
60
        }
61

62

63
        public function print(PrintContext $context): string
64
        {
UNCOV
65
                throw new \LogicException('Cannot directly print ModifierNode');
×
66
        }
67

68

69
        public function printSimple(PrintContext $context, string $expr): string
1✔
70
        {
71
                $expr = FilterNode::printSimple($context, $this->filters, $expr);
1✔
72

73
                $escaper = $context->getEscaper();
1✔
74
                return $this->escape
1✔
75
                        ? $escaper->escape($expr)
1✔
76
                        : $escaper->escapeMandatory($expr, $this->position);
1✔
77
        }
78

79

80
        public function printContentAware(PrintContext $context, string $expr): string
1✔
81
        {
82
                foreach ($this->filters as $filter) {
1✔
83
                        $expr = $filter->printContentAware($context, $expr);
1✔
84
                }
85

86
                return $this->escape
1✔
87
                        ? $context->getEscaper()->escapeContent($expr)
1✔
88
                        : $expr;
1✔
89
        }
90

91

92
        public function &getIterator(): \Generator
1✔
93
        {
94
                foreach ($this->filters as &$filter) {
1✔
95
                        yield $filter;
1✔
96
                }
97
                Helpers::removeNulls($this->filters);
1✔
98
        }
1✔
99
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE TRIAL · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc