/** * Renders a partial template. * * @param string $file A relative file path to the template. * @param array $variables An associative array of variable that should be available * to the rendered template. * @param bool $merge A boolean value indicating if current variable table should be * merged into the partial template. * * @return string */ public function partial(string $file, array $variables = [], bool $merge = false) : string { if ($merge) { $variables = new VariableBucket(array_merge($this->variables->all(), $variables)); } else { $variables = new VariableBucket($variables); } return $this->engine->render($file, $this->sections, $variables, $this->attributes); }
/** * Renders the specified template file. * * @param string $file * @param array $variables * @param array $attributes * * @return string * @throws renderer\buckets\exceptions\StrictVariableException * @throws renderer\buckets\exceptions\VariableWriteException */ public function render(string $file, array $variables = [], array $attributes = []) : string { foreach ($variables as $key => $value) { $this->variables->add($key, $value); } foreach ($attributes as $key => $value) { $this->attributes->add($key, $value); } return $this->engine->render($file, $this->sections, $this->variables, $this->attributes); }