1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-10-18 10:16:16 +02:00

[feature/twig] WIP extension/lexer/some tokenparsers/nodes

PHPBB3-11598
This commit is contained in:
Nathan Guse
2013-06-09 22:09:00 -05:00
parent 7ea0019a71
commit 1da4be04b0
7 changed files with 395 additions and 0 deletions

View File

@@ -0,0 +1,42 @@
<?php
/**
*
* @package phpBB3
* @copyright (c) 2013 phpBB Group
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
*
*/
/**
* @ignore
*/
if (!defined('IN_PHPBB'))
{
exit;
}
class phpbb_template_twig_lexer extends Twig_Lexer
{
protected function lexExpression()
{
/**
* This is some compatibility code to continue supporting expressions such as:
* <!-- IF .blah -->
*
* This does not seem very efficient, but I have not been able to find a better
* method which works properly (maybe lexData can do it better, @todo test this)
*/
$last_element = end($this->tokens);
if ($last_element->getValue() === '.')
{
$last_element2 = prev($this->tokens);
if ($last_element2->getValue() === 'IF')
{
array_pop($this->tokens);
}
}
parent::lexExpression();
}
}