diff --git a/formwork/Template/Layout.php b/formwork/Template/Layout.php index 2e7de3af..2d3dc0fe 100644 --- a/formwork/Template/Layout.php +++ b/formwork/Template/Layout.php @@ -54,7 +54,7 @@ class Layout extends Template * * @return string|null */ - protected function content() + public function content() { return $this->content; } diff --git a/formwork/Template/Template.php b/formwork/Template/Template.php index e6e624e1..b872e1e0 100755 --- a/formwork/Template/Template.php +++ b/formwork/Template/Template.php @@ -124,6 +124,58 @@ class Template return $this->scheme = new Scheme($this->name); } + /** + * Get Assets instance + * + * @return Assets + */ + public function assets() + { + if (!is_null($this->assets)) { + return $this->assets; + } + return $this->assets = new Assets( + $this->path() . 'assets' . DS, + Formwork::instance()->site()->uri('/templates/assets/', false) + ); + } + + /** + * Set template layout + * + * @param string $name + */ + public function layout($name) + { + if (!is_null($this->layout)) { + throw new RuntimeException('The layout for ' . $this->name . ' template is already set'); + } + $this->layout = new Layout($name, $this->page, $this); + } + + /** + * Insert a template + * + * @param string $name + * @param array $vars + */ + public function insert($name, array $vars = array()) + { + if ($name[0] === '_') { + $name = 'partials' . DS . substr($name, 1); + } + + $filename = $this->path() . $name . $this->extension; + + if (!FileSystem::exists($filename)) { + throw new RuntimeException('Template ' . $name . ' not found'); + } + + extract(array_merge($this->vars, $vars)); + + include $filename; + } + /** * Render template * @@ -204,58 +256,6 @@ class Template } } - /** - * Get Assets instance - * - * @return Assets - */ - protected function assets() - { - if (!is_null($this->assets)) { - return $this->assets; - } - return $this->assets = new Assets( - $this->path() . 'assets' . DS, - Formwork::instance()->site()->uri('/templates/assets/', false) - ); - } - - /** - * Set template layout - * - * @param string $name - */ - protected function layout($name) - { - if (!is_null($this->layout)) { - throw new RuntimeException('The layout for ' . $this->name . ' template is already set'); - } - $this->layout = new Layout($name, $this->page, $this); - } - - /** - * Insert a template - * - * @param string $name - * @param array $vars - */ - protected function insert($name, array $vars = array()) - { - if ($name[0] === '_') { - $name = 'partials' . DS . substr($name, 1); - } - - $filename = $this->path() . $name . $this->extension; - - if (!FileSystem::exists($filename)) { - throw new RuntimeException('Template ' . $name . ' not found'); - } - - extract(array_merge($this->vars, $vars)); - - include $filename; - } - public function __call($name, $arguments) { if (TemplateHelpers::has($name)) {