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

44
src/lib/Sage/Template.php Normal file
View File

@@ -0,0 +1,44 @@
<?php namespace Roots\Sage;
use Roots\Sage\Template\Partial;
use Roots\Sage\Template\WrapperInterface;
class Template
{
/** @var Template[] */
public static $instances = [];
/** @var WrapperInterface */
protected $wrapper;
public function __construct(WrapperInterface $wrapper)
{
$this->wrapper = $wrapper;
self::$instances[$wrapper->slug()] = $this;
}
/**
* @return string Layout (FQPN of, e.g., `base-page.php`, `base.php`)
*/
public function layout()
{
return $this->wrapper->wrap();
}
/**
* @return string Main template (FQPN of, e.g., `page.php`, `single.php`, `singular.php`)
*/
public function main()
{
return $this->wrapper->unwrap();
}
/**
* @param string $template Delimited template path
* @return string Partial template (FQPN of, e.g., `content.php`, `page-header.php`
*/
public function partial($template)
{
return (new Partial($template, $this->main()))->path();
}
}