Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Macros: local storage $_l split into (really) local $_l and block sto…
…rage $_b, $_l->extends is not shared [Closes #21][Closes nette/nette#1498]
  • Loading branch information
dg committed Jun 2, 2014
1 parent f1cd44b commit 1c46654
Show file tree
Hide file tree
Showing 26 changed files with 95 additions and 88 deletions.
20 changes: 10 additions & 10 deletions src/Latte/Macros/BlockMacros.php
Expand Up @@ -73,8 +73,8 @@ public function finalize()
$func = '_lb' . substr(md5($this->getCompiler()->getTemplateId() . $name), 0, 10) . '_' . preg_replace('#[^a-z0-9_]#i', '_', $name);
$snippet = $name[0] === '_';
$prolog[] = "//\n// block $name\n//\n"
. "if (!function_exists(\$_l->blocks[" . var_export($name, TRUE) . "][] = '$func')) { "
. "function $func(\$_l, \$_args) { foreach (\$_args as \$__k => \$__v) \$\$__k = \$__v"
. "if (!function_exists(\$_b->blocks[" . var_export($name, TRUE) . "][] = '$func')) { "
. "function $func(\$_b, \$_args) { foreach (\$_args as \$__k => \$__v) \$\$__k = \$__v"
. ($snippet ? '; $_control->redrawControl(' . var_export(substr($name, 1), TRUE) . ', FALSE)' : '')
. "\n?>$code<?php\n}}";
}
Expand Down Expand Up @@ -120,9 +120,9 @@ public function macroInclude(MacroNode $node, PhpWriter $writer)

$name = strpos($destination, '$') === FALSE ? var_export($destination, TRUE) : $destination;
if (isset($this->namedBlocks[$destination]) && !$parent) {
$cmd = "call_user_func(reset(\$_l->blocks[$name]), \$_l, %node.array? + get_defined_vars())";
$cmd = "call_user_func(reset(\$_b->blocks[$name]), \$_b, %node.array? + get_defined_vars())";
} else {
$cmd = 'Latte\Macros\BlockMacros::callBlock' . ($parent ? 'Parent' : '') . "(\$_l, $name, %node.array? + " . ($parent ? 'get_defined_vars' : '$template->getParameters') . '())';
$cmd = 'Latte\Macros\BlockMacros::callBlock' . ($parent ? 'Parent' : '') . "(\$_b, $name, %node.array? + " . ($parent ? 'get_defined_vars' : '$template->getParameters') . '())';
}

if ($node->modifiers) {
Expand All @@ -138,7 +138,7 @@ public function macroInclude(MacroNode $node, PhpWriter $writer)
*/
public function macroIncludeBlock(MacroNode $node, PhpWriter $writer)
{
return $writer->write('$_l->templates[%var]->renderChildTemplate(%node.word, %node.array? + get_defined_vars())',
return $writer->write('$_b->templates[%var]->renderChildTemplate(%node.word, %node.array? + get_defined_vars())',
$this->getCompiler()->getTemplateId());
}

Expand Down Expand Up @@ -213,11 +213,11 @@ public function macroBlock(MacroNode $node, PhpWriter $writer)
} else {
$node->data->leave = TRUE;
$fname = $writer->formatWord($name);
$node->closingCode = "<?php }} " . ($node->name === 'define' ? '' : "call_user_func(reset(\$_l->blocks[$fname]), \$_l, get_defined_vars())") . " ?>";
$node->closingCode = "<?php }} " . ($node->name === 'define' ? '' : "call_user_func(reset(\$_b->blocks[$fname]), \$_b, get_defined_vars())") . " ?>";
$func = '_lb' . substr(md5($this->getCompiler()->getTemplateId() . $name), 0, 10) . '_' . preg_replace('#[^a-z0-9_]#i', '_', $name);
return "\n\n//\n// block $name\n//\n"
. "if (!function_exists(\$_l->blocks[$fname]['{$this->getCompiler()->getTemplateId()}'] = '$func')) { "
. "function $func(\$_l, \$_args) { foreach (\$_args as \$__k => \$__v) \$\$__k = \$__v";
. "if (!function_exists(\$_b->blocks[$fname]['{$this->getCompiler()->getTemplateId()}'] = '$func')) { "
. "function $func(\$_b, \$_args) { foreach (\$_args as \$__k => \$__v) \$\$__k = \$__v";
}
}

Expand All @@ -236,7 +236,7 @@ public function macroBlock(MacroNode $node, PhpWriter $writer)
$prolog = $this->namedBlocks ? '' : "if (\$_l->extends) { ob_end_clean(); return \$template->renderChildTemplate(\$_l->extends, get_defined_vars()); }\n";
$this->namedBlocks[$name] = TRUE;

$include = 'call_user_func(reset($_l->blocks[%var]), $_l, ' . (($node->name === 'snippet' || $node->name === 'snippetArea') ? '$template->getParameters()' : 'get_defined_vars()') . ')';
$include = 'call_user_func(reset($_b->blocks[%var]), $_b, ' . (($node->name === 'snippet' || $node->name === 'snippetArea') ? '$template->getParameters()' : 'get_defined_vars()') . ')';
if ($node->modifiers) {
$include = "ob_start(); $include; echo %modify(ob_get_clean())";
}
Expand Down Expand Up @@ -309,7 +309,7 @@ public function macroIfset(MacroNode $node, PhpWriter $writer)
}
$list = array();
while (($name = $node->tokenizer->fetchWord()) !== FALSE) {
$list[] = $name[0] === '#' ? '$_l->blocks["' . substr($name, 1) . '"]' : $name;
$list[] = $name[0] === '#' ? '$_b->blocks["' . substr($name, 1) . '"]' : $name;
}
return 'if (isset(' . implode(', ', $list) . ')) {';
}
Expand Down
4 changes: 2 additions & 2 deletions src/Latte/Macros/CoreMacros.php
Expand Up @@ -91,7 +91,7 @@ public static function install(Latte\Compiler $compiler)
*/
public function finalize()
{
return array('list($_l, $_g) = $template->initialize('
return array('list($_b, $_g, $_l) = $template->initialize('
. var_export($this->getCompiler()->getTemplateId(), TRUE) . ', '
. var_export($this->getCompiler()->getContentType(), TRUE)
. ')');
Expand Down Expand Up @@ -204,7 +204,7 @@ public function macroTranslate(MacroNode $node, PhpWriter $writer)
*/
public function macroInclude(MacroNode $node, PhpWriter $writer)
{
$code = $writer->write('$_l->templates[%var]->renderChildTemplate(%node.word, %node.array? + $template->getParameters())',
$code = $writer->write('$_b->templates[%var]->renderChildTemplate(%node.word, %node.array? + $template->getParameters())',
$this->getCompiler()->getTemplateId());

if ($node->modifiers) {
Expand Down
19 changes: 11 additions & 8 deletions src/Latte/Template.php
Expand Up @@ -60,28 +60,31 @@ public function getName()


/**
* Initializes local & global storage in template.
* @return [\stdClass, \stdClass]
* Initializes block, global & local storage in template.
* @return [\stdClass, \stdClass, \stdClass]
*/
public function initialize($templateId, $contentType)
{
Runtime\Filters::$xhtml = (bool) preg_match('#xml|xhtml#', $contentType);

// local storage
if (isset($this->params['_l'])) {
$local = $this->params['_l'];
unset($this->params['_l']);
$this->params['_l'] = new \stdClass;

// block storage
if (isset($this->params['_b'])) {
$block = $this->params['_b'];
unset($this->params['_b']);
} else {
$local = new \stdClass;
$block = new \stdClass;
}
$local->templates[$templateId] = $this;
$block->templates[$templateId] = $this;

// global storage
if (!isset($this->params['_g'])) {
$this->params['_g'] = new \stdClass;
}

return array($local, $this->params['_g']);
return array($block, $this->params['_g'], $this->params['_l']);
}


Expand Down
6 changes: 3 additions & 3 deletions tests/Latte/expected/macros.defineblock.phtml
Expand Up @@ -2,13 +2,13 @@
// source: %a%

// prolog Latte\Macros\CoreMacros
list($_l, $_g) = $template->initialize('%[a-z0-9]+%', 'html')
list($_b, $_g, $_l) = $template->initialize('%[a-z0-9]+%', 'html')
;
// prolog Latte\Macros\BlockMacros
//
// block test
//
if (!function_exists($_l->blocks['test'][] = '_%[a-z0-9]+%_test')) { function _%[a-z0-9]+%_test($_l, $_args) { foreach ($_args as $__k => $__v) $$__k = $__v
if (!function_exists($_b->blocks['test'][] = '_%[a-z0-9]+%_test')) { function _%[a-z0-9]+%_test($_b, $_args) { foreach ($_args as $__k => $__v) $$__k = $__v
?> This is definition #<?php echo Latte\Runtime\Filters::escapeHtml($var, ENT_NOQUOTES) ?>

<?php
Expand All @@ -33,4 +33,4 @@ if ($_l->extends) { ob_start();}

<?php if ($_l->extends) { ob_end_clean(); return $template->renderChildTemplate($_l->extends, get_defined_vars()); } ?>

<?php call_user_func(reset($_l->blocks['test']), $_l, array('var' => 20) + get_defined_vars()) ;
<?php call_user_func(reset($_b->blocks['test']), $_b, array('var' => 20) + get_defined_vars()) ;
20 changes: 10 additions & 10 deletions tests/Latte/expected/macros.dynamicblock.phtml
Expand Up @@ -2,13 +2,13 @@
// source: %a%

// prolog Latte\Macros\CoreMacros
list($_l, $_g) = $template->initialize('%[a-z0-9]+%', 'html')
list($_b, $_g, $_l) = $template->initialize('%[a-z0-9]+%', 'html')
;
// prolog Latte\Macros\BlockMacros
//
// block static
//
if (!function_exists($_l->blocks['static'][] = '_%[a-z0-9]+%_static')) { function _%[a-z0-9]+%_static($_l, $_args) { foreach ($_args as $__k => $__v) $$__k = $__v
if (!function_exists($_b->blocks['static'][] = '_%[a-z0-9]+%_static')) { function _%[a-z0-9]+%_static($_b, $_args) { foreach ($_args as $__k => $__v) $$__k = $__v
?> Static block #<?php echo Latte\Runtime\Filters::escapeHtml($var, ENT_NOQUOTES) ?>

<?php
Expand All @@ -30,35 +30,35 @@ if ($_l->extends) { ob_start();}
$var = 10 ?>

<?php if ($_l->extends) { ob_end_clean(); return $template->renderChildTemplate($_l->extends, get_defined_vars()); }
call_user_func(reset($_l->blocks['static']), $_l, get_defined_vars()) ?>
call_user_func(reset($_b->blocks['static']), $_b, get_defined_vars()) ?>


<?php $iterations = 0; foreach ($iterator = $_l->its[] = new Latte\Runtime\CachingIterator(array('dynamic', 'static')) as $name) {

//
// block $name
//
if (!function_exists($_l->blocks[$name]['%[a-z0-9]+%'] = '_%[a-z0-9]+%__name')) { function _%[a-z0-9]+%__name($_l, $_args) { foreach ($_args as $__k => $__v) $$__k = $__v ?>
if (!function_exists($_b->blocks[$name]['%[a-z0-9]+%'] = '_%[a-z0-9]+%__name')) { function _%[a-z0-9]+%__name($_b, $_args) { foreach ($_args as $__k => $__v) $$__k = $__v ?>
Dynamic block #<?php echo Latte\Runtime\Filters::escapeHtml($var, ENT_NOQUOTES) ?>

<?php }} call_user_func(reset($_l->blocks[$name]), $_l, get_defined_vars()) ;$iterations++; } array_pop($_l->its); $iterator = end($_l->its) ?>
<?php }} call_user_func(reset($_b->blocks[$name]), $_b, get_defined_vars()) ;$iterations++; } array_pop($_l->its); $iterator = end($_l->its) ?>

<?php Latte\Macros\BlockMacros::callBlock($_l, 'dynamic', array('var' => 20) + $template->getParameters()) ?>
<?php Latte\Macros\BlockMacros::callBlock($_b, 'dynamic', array('var' => 20) + $template->getParameters()) ?>

<?php call_user_func(reset($_l->blocks['static']), $_l, array('var' => 30) + get_defined_vars()) ?>
<?php call_user_func(reset($_b->blocks['static']), $_b, array('var' => 30) + get_defined_vars()) ?>

<?php Latte\Macros\BlockMacros::callBlock($_l, $name, array('var' => 40) + $template->getParameters()) ?>
<?php Latte\Macros\BlockMacros::callBlock($_b, $name, array('var' => 40) + $template->getParameters()) ?>

<?php

//
// block word$name
//
if (!function_exists($_l->blocks["word$name"]['%[a-z0-9]+%'] = '_%[a-z0-9]+%_word_name')) { function _%[a-z0-9]+%_word_name($_l, $_args) { foreach ($_args as $__k => $__v) $$__k = $__v ;}} call_user_func(reset($_l->blocks["word$name"]), $_l, get_defined_vars()) ?>
if (!function_exists($_b->blocks["word$name"]['%[a-z0-9]+%'] = '_%[a-z0-9]+%_word_name')) { function _%[a-z0-9]+%_word_name($_b, $_args) { foreach ($_args as $__k => $__v) $$__k = $__v ;}} call_user_func(reset($_b->blocks["word$name"]), $_b, get_defined_vars()) ?>

<?php

//
// block "word$name"
//
if (!function_exists($_l->blocks["word$name"]['%[a-z0-9]+%'] = '_%[a-z0-9]+%__word_name_')) { function _%[a-z0-9]+%__word_name_($_l, $_args) { foreach ($_args as $__k => $__v) $$__k = $__v ;}} call_user_func(reset($_l->blocks["word$name"]), $_l, get_defined_vars()) ?>
if (!function_exists($_b->blocks["word$name"]['%[a-z0-9]+%'] = '_%[a-z0-9]+%__word_name_')) { function _%[a-z0-9]+%__word_name_($_b, $_args) { foreach ($_args as $__k => $__v) $$__k = $__v ;}} call_user_func(reset($_b->blocks["word$name"]), $_b, get_defined_vars()) ?>
2 changes: 1 addition & 1 deletion tests/Latte/expected/macros.filters.phtml
Expand Up @@ -2,7 +2,7 @@
// source: %a%

// prolog Latte\Macros\CoreMacros
list($_l, $_g) = $template->initialize('%[a-z0-9]+%', 'html')
list($_b, $_g, $_l) = $template->initialize('%[a-z0-9]+%', 'html')
;
//
// main template
Expand Down
2 changes: 1 addition & 1 deletion tests/Latte/expected/macros.first-sep-last.phtml
Expand Up @@ -2,7 +2,7 @@
// source: %a%

// prolog Latte\Macros\CoreMacros
list($_l, $_g) = $template->initialize('%[a-z0-9]+%', 'html')
list($_b, $_g, $_l) = $template->initialize('%[a-z0-9]+%', 'html')
;
//
// main template
Expand Down
12 changes: 6 additions & 6 deletions tests/Latte/expected/macros.general.html.phtml
Expand Up @@ -2,17 +2,17 @@
// source: %a%

// prolog Latte\Macros\CoreMacros
list($_l, $_g) = $template->initialize('%[a-z0-9]+%', 'html')
list($_b, $_g, $_l) = $template->initialize('%[a-z0-9]+%', 'html')
;
// prolog Latte\Macros\BlockMacros
//
// block menu
//
if (!function_exists($_l->blocks['menu'][] = '_%[a-z0-9]+%_menu')) { function _%[a-z0-9]+%_menu($_l, $_args) { foreach ($_args as $__k => $__v) $$__k = $__v
if (!function_exists($_b->blocks['menu'][] = '_%[a-z0-9]+%_menu')) { function _%[a-z0-9]+%_menu($_b, $_args) { foreach ($_args as $__k => $__v) $$__k = $__v
?><ul>
<?php $iterations = 0; foreach ($iterator = $_l->its[] = new Latte\Runtime\CachingIterator($menu) as $item) { ?>
<li><?php echo Latte\Runtime\Filters::escapeHtml($counter++, ENT_NOQUOTES) ?> <?php if (is_array($item)) { ?>
<?php call_user_func(reset($_l->blocks['menu']), $_l, array('menu' => $item) + get_defined_vars()) ?>
<?php call_user_func(reset($_b->blocks['menu']), $_b, array('menu' => $item) + get_defined_vars()) ?>
<?php } else { echo Latte\Runtime\Filters::escapeHtml($item, ENT_NOQUOTES) ;} ?></li>
<?php $iterations++; } array_pop($_l->its); $iterator = end($_l->its) ?>
</ul>
Expand All @@ -22,7 +22,7 @@ if (!function_exists($_l->blocks['menu'][] = '_%[a-z0-9]+%_menu')) { function _%
//
// block bl
//
if (!function_exists($_l->blocks['bl'][] = '_%[a-z0-9]+%_bl')) { function _%[a-z0-9]+%_bl($_l, $_args) { foreach ($_args as $__k => $__v) $$__k = $__v
if (!function_exists($_b->blocks['bl'][] = '_%[a-z0-9]+%_bl')) { function _%[a-z0-9]+%_bl($_b, $_args) { foreach ($_args as $__k => $__v) $$__k = $__v
?><ul title="block + if + foreach">
<?php $iterations = 0; foreach ($people as $person) { if (strlen($person)===4) { ?>
<li><?php echo Latte\Runtime\Filters::escapeHtml($person, ENT_NOQUOTES) ?></li>
Expand Down Expand Up @@ -157,7 +157,7 @@ var prop2 = <?php echo Latte\Runtime\Filters::escapeJs($people) ?>;


<?php $counter = 0 ;if ($_l->extends) { ob_end_clean(); return $template->renderChildTemplate($_l->extends, get_defined_vars()); }
call_user_func(reset($_l->blocks['menu']), $_l, get_defined_vars()) ?>
call_user_func(reset($_b->blocks['menu']), $_b, get_defined_vars()) ?>


<?php extract(array('varx' => 2), EXTR_SKIP) ;echo Latte\Runtime\Filters::escapeHtml($varx, ENT_NOQUOTES) ?>
Expand Down Expand Up @@ -231,7 +231,7 @@ call_user_func(reset($_l->blocks['menu']), $_l, get_defined_vars()) ?>
<li><?php echo Latte\Runtime\Filters::escapeHtml($template->lower($person), ENT_NOQUOTES) ?></li>
<?php } $iterations++; } ?></ul>

<?php call_user_func(reset($_l->blocks['bl']), $_l, get_defined_vars()) ?>
<?php call_user_func(reset($_b->blocks['bl']), $_b, get_defined_vars()) ?>

<?php if ($_l->ifs[] = (true)) { ?><b><?php } ?>
bold<?php if (array_pop($_l->ifs)) { ?></b><?php } ?>
Expand Down
12 changes: 6 additions & 6 deletions tests/Latte/expected/macros.general.xhtml.phtml
Expand Up @@ -2,17 +2,17 @@
// source: %a%

// prolog Latte\Macros\CoreMacros
list($_l, $_g) = $template->initialize('%[a-z0-9]+%', 'xhtml')
list($_b, $_g, $_l) = $template->initialize('%[a-z0-9]+%', 'xhtml')
;
// prolog Latte\Macros\BlockMacros
//
// block menu
//
if (!function_exists($_l->blocks['menu'][] = '_%[a-z0-9]+%_menu')) { function _%[a-z0-9]+%_menu($_l, $_args) { foreach ($_args as $__k => $__v) $$__k = $__v
if (!function_exists($_b->blocks['menu'][] = '_%[a-z0-9]+%_menu')) { function _%[a-z0-9]+%_menu($_b, $_args) { foreach ($_args as $__k => $__v) $$__k = $__v
?><ul>
<?php $iterations = 0; foreach ($iterator = $_l->its[] = new Latte\Runtime\CachingIterator($menu) as $item) { ?>
<li><?php echo Latte\Runtime\Filters::escapeHtml($counter++, ENT_NOQUOTES) ?> <?php if (is_array($item)) { ?>
<?php call_user_func(reset($_l->blocks['menu']), $_l, array('menu' => $item) + get_defined_vars()) ?>
<?php call_user_func(reset($_b->blocks['menu']), $_b, array('menu' => $item) + get_defined_vars()) ?>
<?php } else { echo Latte\Runtime\Filters::escapeHtml($item, ENT_NOQUOTES) ;} ?></li>
<?php $iterations++; } array_pop($_l->its); $iterator = end($_l->its) ?>
</ul>
Expand All @@ -22,7 +22,7 @@ if (!function_exists($_l->blocks['menu'][] = '_%[a-z0-9]+%_menu')) { function _%
//
// block bl
//
if (!function_exists($_l->blocks['bl'][] = '_%[a-z0-9]+%_bl')) { function _%[a-z0-9]+%_bl($_l, $_args) { foreach ($_args as $__k => $__v) $$__k = $__v
if (!function_exists($_b->blocks['bl'][] = '_%[a-z0-9]+%_bl')) { function _%[a-z0-9]+%_bl($_b, $_args) { foreach ($_args as $__k => $__v) $$__k = $__v
?><ul title="block + if + foreach">
<?php $iterations = 0; foreach ($people as $person) { if (strlen($person)===4) { ?>
<li><?php echo Latte\Runtime\Filters::escapeHtml($person, ENT_NOQUOTES) ?></li>
Expand Down Expand Up @@ -157,7 +157,7 @@ var prop2 = <?php echo Latte\Runtime\Filters::escapeJs($people) ?>;


<?php $counter = 0 ;if ($_l->extends) { ob_end_clean(); return $template->renderChildTemplate($_l->extends, get_defined_vars()); }
call_user_func(reset($_l->blocks['menu']), $_l, get_defined_vars()) ?>
call_user_func(reset($_b->blocks['menu']), $_b, get_defined_vars()) ?>


<?php extract(array('varx' => 2), EXTR_SKIP) ;echo Latte\Runtime\Filters::escapeHtml($varx, ENT_NOQUOTES) ?>
Expand Down Expand Up @@ -231,7 +231,7 @@ call_user_func(reset($_l->blocks['menu']), $_l, get_defined_vars()) ?>
<li><?php echo Latte\Runtime\Filters::escapeHtml($template->lower($person), ENT_NOQUOTES) ?></li>
<?php } $iterations++; } ?></ul>

<?php call_user_func(reset($_l->blocks['bl']), $_l, get_defined_vars()) ?>
<?php call_user_func(reset($_b->blocks['bl']), $_b, get_defined_vars()) ?>

<?php if ($_l->ifs[] = (true)) { ?><b><?php } ?>
bold<?php if (array_pop($_l->ifs)) { ?></b><?php } ?>
Expand Down
2 changes: 1 addition & 1 deletion tests/Latte/expected/macros.ical.phtml
Expand Up @@ -2,7 +2,7 @@
// source: %a%

// prolog Latte\Macros\CoreMacros
list($_l, $_g) = $template->initialize('%[a-z0-9]+%', 'ical')
list($_b, $_g, $_l) = $template->initialize('%[a-z0-9]+%', 'ical')
;
//
// main template
Expand Down
6 changes: 3 additions & 3 deletions tests/Latte/expected/macros.include.inc1.phtml
Expand Up @@ -2,17 +2,17 @@
// source: %a%

// prolog Latte\Macros\CoreMacros
list($_l, $_g) = $template->initialize('%[a-z0-9]+%', 'html')
list($_b, $_g, $_l) = $template->initialize('%[a-z0-9]+%', 'html')
;
//
// main template
//
?>
<p>Included file #1</p>

<?php $_l->templates['%[a-z0-9]+%']->renderChildTemplate("include2.latte", array('localvar' => 20) + $template->getParameters()) ?>
<?php $_b->templates['%[a-z0-9]+%']->renderChildTemplate("include2.latte", array('localvar' => 20) + $template->getParameters()) ?>

<?php $_l->templates['%[a-z0-9]+%']->renderChildTemplate("../include3.latte", $template->getParameters()) ?>
<?php $_b->templates['%[a-z0-9]+%']->renderChildTemplate("../include3.latte", $template->getParameters()) ?>

<textarea>
pre
Expand Down
2 changes: 1 addition & 1 deletion tests/Latte/expected/macros.include.inc2.phtml
Expand Up @@ -2,7 +2,7 @@
// source: %a%

// prolog Latte\Macros\CoreMacros
list($_l, $_g) = $template->initialize('%[a-z0-9]+%', 'html')
list($_b, $_g, $_l) = $template->initialize('%[a-z0-9]+%', 'html')
;
//
// main template
Expand Down
2 changes: 1 addition & 1 deletion tests/Latte/expected/macros.include.inc3.phtml
Expand Up @@ -2,7 +2,7 @@
// source: %a%

// prolog Latte\Macros\CoreMacros
list($_l, $_g) = $template->initialize('%[a-z0-9]+%', 'html')
list($_b, $_g, $_l) = $template->initialize('%[a-z0-9]+%', 'html')
;
//
// main template
Expand Down
4 changes: 2 additions & 2 deletions tests/Latte/expected/macros.include.phtml
Expand Up @@ -2,11 +2,11 @@
// source: %a%

// prolog Latte\Macros\CoreMacros
list($_l, $_g) = $template->initialize('%[a-z0-9]+%', 'html')
list($_b, $_g, $_l) = $template->initialize('%[a-z0-9]+%', 'html')
;
//
// main template
//
?>

<?php ob_start(); $_l->templates['%[a-z0-9]+%']->renderChildTemplate('subdir/include1.latte', array('localvar' => 10) + $template->getParameters()); echo $template->indent(ob_get_clean()) ;
<?php ob_start(); $_b->templates['%[a-z0-9]+%']->renderChildTemplate('subdir/include1.latte', array('localvar' => 10) + $template->getParameters()); echo $template->indent(ob_get_clean()) ;
4 changes: 2 additions & 2 deletions tests/Latte/expected/macros.includeblock.inc.phtml
Expand Up @@ -2,13 +2,13 @@
// source: %a%

// prolog Latte\Macros\CoreMacros
list($_l, $_g) = $template->initialize('%[a-z0-9]+%', 'html')
list($_b, $_g, $_l) = $template->initialize('%[a-z0-9]+%', 'html')
;
// prolog Latte\Macros\BlockMacros
//
// block test
//
if (!function_exists($_l->blocks['test'][] = '_%[a-z0-9]+%_test')) { function _%[a-z0-9]+%_test($_l, $_args) { foreach ($_args as $__k => $__v) $$__k = $__v
if (!function_exists($_b->blocks['test'][] = '_%[a-z0-9]+%_test')) { function _%[a-z0-9]+%_test($_b, $_args) { foreach ($_args as $__k => $__v) $$__k = $__v
?> Test block
<?php
}}
Expand Down

0 comments on commit 1c46654

Please sign in to comment.