diff --git a/.gitignore b/.gitignore index c757210654..06b13923f5 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ *~ /phpunit.xml +/phpBB/cache/twig/* /phpBB/cache/*.html /phpBB/cache/*.php /phpBB/cache/*.lock diff --git a/phpBB/includes/template/twig/extension.php b/phpBB/includes/template/twig/extension.php index c121a21800..718909ee50 100644 --- a/phpBB/includes/template/twig/extension.php +++ b/phpBB/includes/template/twig/extension.php @@ -39,8 +39,20 @@ class phpbb_template_twig_extension extends Twig_Extension return array( array(), array( + // @todo check if all these are needed (or others) 'eq' => array('precedence' => 20, 'class' => 'Twig_Node_Expression_Binary_Equal', 'associativity' => Twig_ExpressionParser::OPERATOR_LEFT), - '!==' => array('precedence' => 20, 'class' => 'Twig_Node_Expression_Binary_NotEqual', 'associativity' => Twig_ExpressionParser::OPERATOR_LEFT), + + 'ne' => array('precedence' => 20, 'class' => 'Twig_Node_Expression_Binary_NotEqual', 'associativity' => Twig_ExpressionParser::OPERATOR_LEFT), + 'neq' => array('precedence' => 20, 'class' => 'Twig_Node_Expression_Binary_NotEqual', 'associativity' => Twig_ExpressionParser::OPERATOR_LEFT), + '<>' => array('precedence' => 20, 'class' => 'Twig_Node_Expression_Binary_NotEqual', 'associativity' => Twig_ExpressionParser::OPERATOR_LEFT), + + '===' => array('precedence' => 20, 'class' => 'phpbb_template_twig_node_expression_binary_equalequal', 'associativity' => Twig_ExpressionParser::OPERATOR_LEFT), + '!==' => array('precedence' => 20, 'class' => 'phpbb_template_twig_node_expression_binary_notequalequal', 'associativity' => Twig_ExpressionParser::OPERATOR_LEFT), + + 'gt' => array('precedence' => 20, 'class' => 'Twig_Node_Expression_Binary_Greater', 'associativity' => Twig_ExpressionParser::OPERATOR_LEFT), + 'gte' => array('precedence' => 20, 'class' => 'Twig_Node_Expression_Binary_GreaterEqual', 'associativity' => Twig_ExpressionParser::OPERATOR_LEFT), + 'lt' => array('precedence' => 20, 'class' => 'Twig_Node_Expression_Binary_Less', 'associativity' => Twig_ExpressionParser::OPERATOR_LEFT), + 'lte' => array('precedence' => 20, 'class' => 'Twig_Node_Expression_Binary_LessEqual', 'associativity' => Twig_ExpressionParser::OPERATOR_LEFT), ), ); } diff --git a/phpBB/includes/template/twig/lexer.php b/phpBB/includes/template/twig/lexer.php index 71e3e9c27e..ea161bf730 100644 --- a/phpBB/includes/template/twig/lexer.php +++ b/phpBB/includes/template/twig/lexer.php @@ -45,7 +45,7 @@ class phpbb_template_twig_lexer extends Twig_Lexer // This strips the $ inside of a tag directly after the token, which was used in #', '', $code); - // This strips the . inside of a tag directly before a variable name, which was used in #', array($this, 'tag_if_cleanup'), $code); // Replace all of our starting tokens, with Twig style, {% TOKEN %} @@ -61,12 +61,13 @@ class phpbb_template_twig_lexer extends Twig_Lexer /** * preg_replace_callback to clean up IF statements * - * This strips the . inside of a tag directly before a variable name, which was used in '; + return ''; } } diff --git a/phpBB/includes/template/twig/node/expression/binary/equalequal.php b/phpBB/includes/template/twig/node/expression/binary/equalequal.php new file mode 100644 index 0000000000..3a0c79c839 --- /dev/null +++ b/phpBB/includes/template/twig/node/expression/binary/equalequal.php @@ -0,0 +1,16 @@ +raw('==='); + } +} diff --git a/phpBB/includes/template/twig/node/expression/binary/notequalequal.php b/phpBB/includes/template/twig/node/expression/binary/notequalequal.php new file mode 100644 index 0000000000..b53bc56b2d --- /dev/null +++ b/phpBB/includes/template/twig/node/expression/binary/notequalequal.php @@ -0,0 +1,16 @@ +raw('!=='); + } +} diff --git a/phpBB/includes/template/twig/twig.php b/phpBB/includes/template/twig/twig.php index a067827f70..e12b62be63 100644 --- a/phpBB/includes/template/twig/twig.php +++ b/phpBB/includes/template/twig/twig.php @@ -108,13 +108,17 @@ class phpbb_template_twig implements phpbb_template $this->extension_manager = $extension_manager; $loader = new Twig_Loader_Filesystem($phpbb_root_path . 'styles/prosilver/template/'); + //$loader = new Twig_Loader_Filesystem($phpbb_root_path . 'adm/style/'); $this->twig = new Twig_Environment($loader, array( - //'cache' => $phpbb_root_path . 'cache/twig/', + 'cache' => $phpbb_root_path . 'cache/twig/', 'debug' => true, 'auto_reload' => true, 'autoescape' => false, )); + // Clear previous cache files (while WIP) + $this->twig->clearCacheFiles(); + $this->twig->addExtension(new phpbb_template_twig_extension); $lexer = new phpbb_template_twig_lexer($this->twig);