Files
sage/src/lib/Sage/Template.php
Kalen Johnson 2124163de0 Namespaces on own line (#1712)
`namespace` declarations appear on their own line in PHP FIG examples as well as in common PHP frameworks. While not officially part of PSR-2, we should still follow this common practice of not putting `namespace` declaration on the same line as `<?php`.

- http://www.php-fig.org/psr/psr-2/
- https://github.com/laravel/laravel/blob/master/app/User.php#L1-L3
- https://github.com/symfony/filesystem/blob/master/Filesystem.php#L1-L12
- https://github.com/zendframework/zend-mail/blob/master/src/Address.php#L1-L10
2016-09-09 04:24:09 -07:00

47 lines
1.0 KiB
PHP

<?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();
}
}