/**
  * @param \Twig_Compiler $compiler
  */
 public function compile(\Twig_Compiler $compiler)
 {
     $compiler->addDebugInfo($this);
     $body = $this->getNode('body');
     if ($body instanceof \Twig_Node_Expression_Constant) {
         $body = new \Twig_Node_Expression_Constant(trim($body->getAttribute('value')), $body->getLine());
     } elseif ($body instanceof \Twig_Node_Text) {
         $body = new \Twig_Node_Expression_Constant(trim($body->getAttribute('data')), $body->getLine());
     }
     $compiler->write('echo $this->env->getExtension(\'ivoaz_content_editable\')->render(')->subcompile($body)->raw(',')->repr($this->getAttribute('name'))->raw(',')->repr($this->getAttribute('options'))->raw(');');
 }
Esempio n. 2
0
 public function __construct(Twig_NodeInterface $node, $name, Twig_NodeInterface $arguments = null, $lineno)
 {
     if ($node instanceof Twig_Node_Expression_Name) {
         $node->setAttribute('is_defined_test', true);
     } elseif ($node instanceof Twig_Node_Expression_GetAttr) {
         $node->setAttribute('is_defined_test', true);
         $this->changeIgnoreStrictCheck($node);
     } elseif ($node instanceof Twig_Node_Expression_Constant || $node instanceof Twig_Node_Expression_Array) {
         $node = new Twig_Node_Expression_Constant(true, $node->getLine());
     } else {
         throw new Twig_Error_Syntax('The "defined" test only works with simple variables.', $this->getLine());
     }
     parent::__construct($node, $name, $arguments, $lineno);
 }