Skip to content

Commit

Permalink
macro {includeblock} trims output
Browse files Browse the repository at this point in the history
  • Loading branch information
dg committed Aug 22, 2014
1 parent 5a7c855 commit f4d8efb
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/Latte/Macros/BlockMacros.php
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ public function macroInclude(MacroNode $node, PhpWriter $writer)
*/
public function macroIncludeBlock(MacroNode $node, PhpWriter $writer)
{
return $writer->write('$_b->templates[%var]->renderChildTemplate(%node.word, %node.array? + get_defined_vars())',
return $writer->write('ob_start(); $_b->templates[%var]->renderChildTemplate(%node.word, %node.array? + get_defined_vars()); echo rtrim(ob_get_clean())',
$this->getCompiler()->getTemplateId());
}

Expand Down
1 change: 1 addition & 0 deletions tests/Latte/expected/macros.includeblock.html
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@



Test block
3 changes: 2 additions & 1 deletion tests/Latte/expected/macros.includeblock.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ list($_b, $_g, $_l) = $template->initialize('%[a-z0-9]+%', 'html')
//
?>

<?php $_b->templates['%[a-z0-9]+%']->renderChildTemplate('includeblock.inc.latte', get_defined_vars()) ?>
<?php ob_start(); $_b->templates['%[a-z0-9]+%']->renderChildTemplate('includeblock.inc.latte', get_defined_vars()); echo rtrim(ob_get_clean()) ?>


<?php Latte\Macros\BlockMacros::callBlock($_b, 'test', $template->getParameters()) ;
3 changes: 2 additions & 1 deletion tests/Latte/expected/macros.inheritance.child1.child.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ if ($_l->extends) { ob_start();}
// main template
// ?>

<?php $_b->templates['%[a-z0-9]+%']->renderChildTemplate('includeblock.inc.latte', get_defined_vars()) ?>
<?php ob_start(); $_b->templates['%[a-z0-9]+%']->renderChildTemplate('includeblock.inc.latte', get_defined_vars()); echo rtrim(ob_get_clean()) ?>


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

0 comments on commit f4d8efb

Please sign in to comment.