Пример #1
0
 public function testGetCompiledTemplateLiteral()
 {
     $provider = new ArrayProvider(['test.htpl' => '<w-literal>{var}</w-literal>']);
     $htpl = new Htpl($provider);
     $compiler = new Compiler($htpl);
     $result = $compiler->getCompiledTemplate('test.htpl');
     $this->assertInstanceOf('Webiny\\Htpl\\Processor\\Template', $result);
     $this->assertSame('{var}', trim($result->getSource()));
 }
Пример #2
0
 /**
  * Fetch the template from the given location, parse it and return the output.
  *
  * @param string $template   Path to the template.
  * @param array  $parameters A list of parameters to pass to the template.
  *
  * @return Template
  */
 public function build($template, $parameters = [])
 {
     $this->assignArray($parameters);
     $this->template = $template;
     if (!isset($this->compiledTemplates[$template])) {
         // compile the template
         $compiler = new Compiler($this);
         $this->compiledTemplates[$template] = $compiler->getCompiledTemplate($template);
     }
     return $this->compiledTemplates[$template];
 }