Goetas\Twital\SourceAdapter::load PHP Method

load() public method

Gets the raw template source code and return a {Goetas\Twital\Template} instance.
public load ( string $string ) : Template
$string string
return Template
    public function load($string);

Usage Example

Beispiel #1
0
 /**
  *
  * @param SourceAdapter $adapter
  * @param string $source
  * @return string
  */
 public function compile(SourceAdapter $adapter, $source)
 {
     $this->initExtensions();
     $sourceEvent = new SourceEvent($this, $source);
     $this->dispatcher->dispatch('compiler.pre_load', $sourceEvent);
     $template = $adapter->load($sourceEvent->getTemplate());
     $templateEvent = new TemplateEvent($this, $template);
     $this->dispatcher->dispatch('compiler.post_load', $templateEvent);
     $compiler = new Compiler($this, isset($this->options['lexer']) ? $this->options['lexer'] : array());
     $compiler->compile($templateEvent->getTemplate()->getDocument());
     $templateEvent = new TemplateEvent($this, $templateEvent->getTemplate());
     $this->dispatcher->dispatch('compiler.pre_dump', $templateEvent);
     $source = $adapter->dump($templateEvent->getTemplate());
     $sourceEvent = new SourceEvent($this, $source);
     $this->dispatcher->dispatch('compiler.post_dump', $sourceEvent);
     return $sourceEvent->getTemplate();
 }
SourceAdapter