Permalink
Browse files

Merge pull request #211 from thephpleague/override-default-layouts

Override Default Layouts #210
  • Loading branch information...
ragboyjr committed Jan 22, 2018
2 parents b242194 + e13bfbd commit 2377d3f42fd17f9542d60db798a682ef4addf693
@@ -21,6 +21,10 @@ public function renderTemplate(Plates\Template $template, Plates\RenderTemplate
$ref = $template->reference;
$contents = $this->render->renderTemplate($template, $rt ?: $this);
if ($ref()->get('layout')) {
return $contents;
}
$layout = $ref()->fork($this->layout_path);
$ref()->with('layout', $layout->reference);
@@ -0,0 +1,3 @@
<p>
<?=$v->section('content')?>
</p>
@@ -1 +1,4 @@
<?php if (isset($override)): ?>
<?php $v->layout('_override') ?>
<?php endif; ?>
<div>main - <?=$v->insert('partial')?></div>
@@ -25,4 +25,13 @@
html;
expect($this->plates->render('main', [], ['no_layout' => true]))->equal($html);
});
it('allows an override of the default layout', function() {
$html = <<<html
<p>
<div>main - partial</div>
</p>
html;
expect($this->plates->render('main', ['override' => true]))->equal($html);
});
});

0 comments on commit 2377d3f

Please sign in to comment.