/** * Create new Template instance. * @param Engine $engine * @param string $name */ public function __construct(Engine $engine, $name) { set_error_handler(array($this, 'renderErrorHandler')); $this->engine = $engine; $this->name = new Name($engine, $name); $this->data($this->engine->getData($name)); }
/** * Loads the template. * * @param string $template The template relative path * @param array $vars The template variables * * @throws TemplateNotFoundException When template does not exist * @throws UnsupportedTemplateException When template format is not supported * * @return TemplateInterface */ public function loadTemplate($template, array $vars = []) { if (!$this->supports($template)) { throw new UnsupportedTemplateException(sprintf('Template %s is not supported by this engine.', $template)); } if (!$this->exists($template)) { throw new TemplateNotFoundException(sprintf('Template %s does not exist.', $template)); } return new Template($this->plates->path($template), array_merge($this->plates->getData(), $vars)); }
/** * Create new Template instance. * @param Engine $engine * @param string $name */ public function __construct(Engine $engine, $name) { $this->engine = $engine; $this->name = new Name($engine, $name); $this->data($this->engine->getData($name)); }