Exemple #1
0
 public function parse(Apishka_Templater_Token $token)
 {
     $lineno = $token->getLine();
     $stream = $this->parser->getStream();
     if ($stream->test(Apishka_Templater_Token::BLOCK_END_TYPE)) {
         $value = 'html';
     } else {
         $expr = $this->parser->getExpressionParser()->parseExpression();
         if (!$expr instanceof Apishka_Templater_Node_Expression_Constant) {
             throw new Apishka_Templater_Error_Syntax('An escaping strategy must be a string or false.', $stream->getCurrent()->getLine(), $stream->getFilename());
         }
         $value = $expr->getAttribute('value');
     }
     $stream->expect(Apishka_Templater_Token::BLOCK_END_TYPE);
     $body = $this->parser->subparse(array($this, 'decideBlockEnd'), true);
     $stream->expect(Apishka_Templater_Token::BLOCK_END_TYPE);
     return Apishka_Templater_Node_AutoEscape::apishka($value, $body, $lineno, $this->getTag());
 }
Exemple #2
0
 public function getTests()
 {
     $body = Apishka_Templater_Node::apishka(array(Apishka_Templater_Node_Text::apishka('foo', 1)));
     $node = Apishka_Templater_Node_AutoEscape::apishka(true, $body, 1);
     return array(array($node, "// line 1\necho \"foo\";"));
 }