mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-25 12:35:55 +02:00
Merge pull request #1705 from EXreaction/ticket/11833
Fix invalid template loop & prevent Twig from throwing errors in invalid uses of BEGINELSE
This commit is contained in:
@ -161,6 +161,9 @@ class phpbb_template_twig_lexer extends Twig_Lexer
|
||||
$subset = trim(substr($matches[2], 1, -1)); // Remove parenthesis
|
||||
$body = $matches[3];
|
||||
|
||||
// Replace <!-- BEGINELSE -->
|
||||
$body = str_replace('<!-- BEGINELSE -->', '{% else %}', $body);
|
||||
|
||||
// Is the designer wanting to call another loop in a loop?
|
||||
// <!-- BEGIN loop -->
|
||||
// <!-- BEGIN !loop2 -->
|
||||
@ -205,9 +208,6 @@ class phpbb_template_twig_lexer extends Twig_Lexer
|
||||
return "{% for {$name} in {$parent}{$name}{$subset} %}{$body}{% endfor %}";
|
||||
};
|
||||
|
||||
// Replace <!-- BEGINELSE --> correctly, only needs to be done once
|
||||
$code = str_replace('<!-- BEGINELSE -->', '{% else %}', $code);
|
||||
|
||||
return preg_replace_callback('#<!-- BEGIN ([!a-zA-Z0-9_]+)(\([0-9,\-]+\))? -->(.+?)<!-- END \1 -->#s', $callback, $code);
|
||||
}
|
||||
|
||||
|
@ -88,7 +88,7 @@
|
||||
<tr>
|
||||
<td class="bg1" colspan="<!-- IF S_CLEAR_ALLOWED -->5<!-- ELSE -->4<!-- ENDIF -->" align="center"><span class="gen">{L_NO_ENTRIES}</span></td>
|
||||
</tr>
|
||||
<!-- END usernames -->
|
||||
<!-- END usernotes -->
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
|
Reference in New Issue
Block a user