mirror of
https://github.com/getformwork/formwork.git
synced 2025-02-25 02:02:57 +01:00
Reorder and change some methods visibility in Template
and Layout
This commit is contained in:
parent
9f518cbf56
commit
7ed745333a
@ -54,7 +54,7 @@ class Layout extends Template
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
protected function content()
|
||||
public function content()
|
||||
{
|
||||
return $this->content;
|
||||
}
|
||||
|
@ -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)) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user