mirror of
https://github.com/getformwork/formwork.git
synced 2025-02-24 09:42:43 +01:00
Improve Template::insert()
providing filename checks
This commit is contained in:
parent
192bedd410
commit
a0842b4f1c
@ -141,15 +141,26 @@ class Template
|
||||
}
|
||||
|
||||
/**
|
||||
* Insert a partial template
|
||||
* Insert a template
|
||||
*
|
||||
* @param string $filename
|
||||
* @param string $name
|
||||
* @param array $vars
|
||||
*/
|
||||
protected function insert($filename, $vars = array())
|
||||
protected function insert($name, $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 $this->path . str_replace('_', 'partials' . DS, $filename) . $this->extension;
|
||||
|
||||
include $filename;
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user