Rework template wrapper, bring back template_part()

This commit is contained in:
QWp6t
2016-07-15 05:31:02 -07:00
parent 0a71544b83
commit eb3a7add85
8 changed files with 130 additions and 109 deletions

View File

@@ -2,29 +2,17 @@
use Roots\Sage\Asset;
use Roots\Sage\Assets\JsonManifest;
use Roots\Sage\Template\WrapperCollection;
use Roots\Sage\Template\WrapperInterface;
use Roots\Sage\Template;
/**
* @param WrapperInterface $wrapper
* @param string $slug
* @return string
* @throws \Exception
* @SuppressWarnings(PHPMD.StaticAccess) This is a helper function, so we can suppress this warning
*/
function template_wrap(WrapperInterface $wrapper, $slug = 'base')
function template($layout = 'base')
{
WrapperCollection::add($wrapper, $slug);
return $wrapper->getWrapper();
return Template::$instances[$layout];
}
/**
* @param string $slug
* @return string
*/
function template_unwrap($slug = 'base')
function template_part($template, array $context = [], $layout = 'base')
{
return WrapperCollection::get($slug)->getTemplate();
extract($context);
include template($layout)->partial($template);
}
/**