dump() public method

Gets a {Template} instance and return the raw template source code.
public dump ( Template $dom ) : string
$dom Template
return string
示例#1
0
文件: Twital.php 项目: goetas/twital
 /**
  *
  * @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();
 }