diff options
author | rxu <rxu@mail.ru> | 2017-08-15 15:41:56 +0700 |
---|---|---|
committer | rxu <rxu@mail.ru> | 2017-08-15 15:41:56 +0700 |
commit | aabb9d2e488e465d48d9910f98a861ab96f55f74 (patch) | |
tree | ac658a6a7090d4f35bde5222ca5e2d7c32e15fa7 | |
parent | 1e605efaf126f5474bb1be99e7fdaed834ebb2a0 (diff) | |
download | forums-aabb9d2e488e465d48d9910f98a861ab96f55f74.tar forums-aabb9d2e488e465d48d9910f98a861ab96f55f74.tar.gz forums-aabb9d2e488e465d48d9910f98a861ab96f55f74.tar.bz2 forums-aabb9d2e488e465d48d9910f98a861ab96f55f74.tar.xz forums-aabb9d2e488e465d48d9910f98a861ab96f55f74.zip |
[ticket/15323] Allow Twig syntax in bbcode.html
PHPBB3-15323
-rw-r--r-- | phpBB/includes/bbcode.php | 5 | ||||
-rw-r--r-- | phpBB/phpbb/textformatter/s9e/factory.php | 4 |
2 files changed, 7 insertions, 2 deletions
diff --git a/phpBB/includes/bbcode.php b/phpBB/includes/bbcode.php index e8492a82a3..6572c0ad2c 100644 --- a/phpBB/includes/bbcode.php +++ b/phpBB/includes/bbcode.php @@ -501,7 +501,10 @@ class bbcode // Turn template blocks into PHP assignment statements for the values of $bbcode_tpl.. $this->bbcode_template = array(); - $matches = preg_match_all('#<!-- BEGIN (.*?) -->(.*?)<!-- END (?:.*?) -->#', $tpl, $match); + // Capture the BBCode template matches + // Allow phpBB template or the Twig syntax + $matches = (preg_match_all('#<!-- BEGIN (.*?) -->(.*?)<!-- END (?:.*?) -->#', $tpl, $match)) ?: + preg_match_all('#{% for (.*?) in .*? %}(.*?){% endfor %}#s', $tpl, $match); for ($i = 0; $i < $matches; $i++) { diff --git a/phpBB/phpbb/textformatter/s9e/factory.php b/phpBB/phpbb/textformatter/s9e/factory.php index 7719ce5afa..13bfc7b5e9 100644 --- a/phpBB/phpbb/textformatter/s9e/factory.php +++ b/phpBB/phpbb/textformatter/s9e/factory.php @@ -518,7 +518,9 @@ class factory implements \phpbb\textformatter\cache_interface protected function extract_templates($template) { // Capture the template fragments - preg_match_all('#<!-- BEGIN (.*?) -->(.*?)<!-- END .*? -->#s', $template, $matches, PREG_SET_ORDER); + // Allow either phpBB template or the Twig syntax + preg_match_all('#<!-- BEGIN (.*?) -->(.*?)<!-- END .*? -->#s', $template, $matches, PREG_SET_ORDER) ?: + preg_match_all('#{% for (.*?) in .*? %}(.*?){% endfor %}#s', $template, $matches, PREG_SET_ORDER); $fragments = array(); foreach ($matches as $match) |