/** * @param HaploTemplate $template * @param array $escapeTypes */ public function assignToTemplate(HaploTemplate $template, array $escapeTypes = []) { $this->nonce = $this->app->nonce->get(); foreach ($this->getPublicProperties() as $object) { $property = $object->name; if (array_key_exists($property, $escapeTypes)) { $template->set($property, $this->{$property}, array('escapeMethod' => $escapeTypes[$property])); } else { $template->set($property, $this->{$property}, array('escapeMethod' => 'escapeAttr')); } } }
/** * Include another template inside the main template (called within the template file). * Included template inherits parent templates variables and can optionally set its own * which live within the scope of that included template only. * * @param string $filename Filename for template to include - uses the same file paths as the parent * @param array $vars Optionally pass additional variables to the template **/ protected function incTemplate($filename, array $vars = array()) { $template = new HaploTemplate($this->app, $filename); $template->vars = $this->vars; if (count($vars)) { foreach ($vars as $key => $value) { $template->set($key, $value); } } echo $template->render(); }