示例#1
0
 public function testGetTags()
 {
     $lexer = new Lexer(array('{#', '#}'), array('{%', '%}'), array('{#', '/}'));
     $this->assertEquals($lexer->getTags(), array('tag_comment' => array('{#', '#}'), 'tag_block' => array('{%', '%}'), 'tag_variable' => array('{#', '/}')));
 }
示例#2
0
 /**
  * Get the lexer for Twig to use.
  *
  * @param Twig_Environment $twig
  * @param array            $delimiters Opening & closing tags for comments, blocks & variables.
  * @return Twig_Lexer
  */
 public function getLexer(Twig_Environment $twig = null, array $delimiters = null)
 {
     if ($this->lexer !== null) {
         return $this->lexer;
     } elseif ($twig === null) {
         // You must pass in an instance of Twig if the lexer has not already been set
         throw new InvalidArgumentException('No lexer set, you must pass an instance of Twig_Environment in!');
     }
     if ($delimiters === null) {
         $delimiters = $this->app['config']->get('twigbridge::delimiters', array('tag_comment' => array('{#', '#}'), 'tag_block' => array('{%', '%}'), 'tag_variable' => array('{{', '}}')));
     }
     $lexer = new Twig\Lexer(isset($delimiters['tag_comment']) ? $delimiters['tag_comment'] : array(), isset($delimiters['tag_block']) ? $delimiters['tag_block'] : array(), isset($delimiters['tag_variable']) ? $delimiters['tag_variable'] : array());
     return $lexer->getLexer($twig);
 }