Gush\Helper\TemplateHelper::registerTemplate PHP Метод

registerTemplate() публичный Метод

Registers a template.
public registerTemplate ( Gush\Template\TemplateInterface $template )
$template Gush\Template\TemplateInterface
    public function registerTemplate(TemplateInterface $template)
    {
        $templateName = $template->getName();
        $parts = explode('/', $templateName);
        if (count($parts) !== 2) {
            throw new \InvalidArgumentException(sprintf('Template name "%s" is not formatted properly, should be like "domain/template-name"', $templateName));
        }
        list($domain, $name) = $parts;
        $this->templates[$domain][$name] = $template;
    }

Usage Example

Пример #1
0
 /**
  * @test
  */
 public function binds_and_renders()
 {
     $this->input->setOption('test-option', 'test-option');
     $this->template->getName()->willReturn('test/foobar')->shouldBeCalled();
     $this->template->bind(['author' => 'cslucano'])->shouldBeCalled();
     $this->template->render()->willReturn('foo')->shouldBeCalled();
     $this->helper->registerTemplate($this->template->reveal());
     $res = $this->helper->bindAndRender(['author' => 'cslucano'], 'test', 'foobar');
     $this->assertEquals('foo', $res);
 }