aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/includes/template/twig/lexer.php
diff options
context:
space:
mode:
Diffstat (limited to 'phpBB/includes/template/twig/lexer.php')
-rw-r--r--phpBB/includes/template/twig/lexer.php42
1 files changed, 42 insertions, 0 deletions
diff --git a/phpBB/includes/template/twig/lexer.php b/phpBB/includes/template/twig/lexer.php
new file mode 100644
index 0000000000..45b97acf8c
--- /dev/null
+++ b/phpBB/includes/template/twig/lexer.php
@@ -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();
+ }
+}