コード例 #1
0
 /**
  * @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(');');
 }
コード例 #2
0
ファイル: Default.php プロジェクト: ceroberoz/kurs
 public function __construct(Twig_NodeInterface $node, Twig_Node_Expression_Constant $filterName, Twig_NodeInterface $arguments, $lineno, $tag = null)
 {
     $default = new Twig_Node_Expression_Filter($node, new Twig_Node_Expression_Constant('_default', $node->getLine()), $arguments, $node->getLine());
     if ('default' === $filterName->getAttribute('value') && ($node instanceof Twig_Node_Expression_Name || $node instanceof Twig_Node_Expression_GetAttr)) {
         $test = new Twig_Node_Expression_Test_Defined(clone $node, 'defined', new Twig_Node(), $node->getLine());
         $false = count($arguments) ? $arguments->getNode(0) : new Twig_Node_Expression_Constant('', $node->getLine());
         $node = new Twig_Node_Expression_Conditional($test, $default, $false, $node->getLine());
     } else {
         $node = $default;
     }
     parent::__construct($node, $filterName, $arguments, $lineno, $tag);
 }
コード例 #3
0
ファイル: Defined.php プロジェクト: mat33470/PFA
 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);
 }
コード例 #4
0
ファイル: ExpressionParser.php プロジェクト: dev-lav/htdocs
 public function parseFilterExpressionRaw($node, $tag = null)
 {
     while (true) {
         $token = $this->parser->getStream()->expect(Twig_Token::NAME_TYPE);
         $name = new Twig_Node_Expression_Constant($token->getValue(), $token->getLine());
         if (!$this->parser->getStream()->test(Twig_Token::PUNCTUATION_TYPE, '(')) {
             $arguments = new Twig_Node();
         } else {
             $arguments = $this->parseArguments(true);
         }
         $class = $this->getFilterNodeClass($name->getAttribute('value'), $token->getLine());
         $node = new $class($node, $name, $arguments, $token->getLine(), $tag);
         if (!$this->parser->getStream()->test(Twig_Token::PUNCTUATION_TYPE, '|')) {
             break;
         }
         $this->parser->getStream()->next();
     }
     return $node;
 }
コード例 #5
0
 public function testConstructor()
 {
     $node = new Twig_Node_Expression_Constant('foo', 1);
     $this->assertEquals('foo', $node->getAttribute('value'));
 }