Skip to content

Commit 140f7a1

Browse files
committed
UIMacros: own handler for {includeblock}
1 parent fcfc072 commit 140f7a1

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

src/Bridges/ApplicationLatte/UIMacros.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ public static function install(Latte\Compiler $compiler)
3636
$me->addMacro('plink', [$me, 'macroLink']);
3737
$me->addMacro('link', [$me, 'macroLink']);
3838
$me->addMacro('ifCurrent', [$me, 'macroIfCurrent'], '}'); // deprecated; use n:class="$presenter->linkCurrent ? ..."
39+
$me->addMacro('includeblock', [$me, 'macroIncludeBlock']);
3940
}
4041

4142

@@ -108,6 +109,20 @@ public function macroIfCurrent(MacroNode $node, PhpWriter $writer)
108109
}
109110

110111

112+
/**
113+
* {includeblock "file"}
114+
*/
115+
public function macroIncludeBlock(MacroNode $node, PhpWriter $writer)
116+
{
117+
if ($node->modifiers) {
118+
throw new CompileException("Modifiers are not allowed in {{$node->name}}");
119+
}
120+
return $writer->write(
121+
'ob_start(function () {}); $_g->includingBlock = isset($_g->includingBlock) ? ++$_g->includingBlock : 1; $this->renderChildTemplate(%node.word, %node.array? + get_defined_vars()); $_g->includingBlock--; echo rtrim(ob_get_clean())'
122+
);
123+
}
124+
125+
111126
/** @deprecated */
112127
public static function renderSnippets(Nette\Application\UI\Control $control, \stdClass $local, array $params)
113128
{

0 commit comments

Comments
 (0)