- Fixed a bug added in previous commit

This commit is contained in:
Dave M. 2023-02-02 18:12:31 +00:00
parent acd9f8c72e
commit e9b2f0ece3
3 changed files with 15 additions and 9 deletions

View File

@ -6,7 +6,7 @@
"authors": [
{
"name": "Dave Mc Nicoll",
"email": "mcndave@gmail.com"
"email": "info@mcnd.ca"
}
],
"autoload": {

View File

@ -88,6 +88,11 @@ abstract class Context {
}
public function tokenName(string $token) : string
{
return explode('.', $token)[0];
}
public function tokenOptions(string $token, bool $export = false) : array|string
{
$options = explode('.', strtolower($token));

View File

@ -22,21 +22,22 @@ class PrintExtension implements Extension {
{
$opt = $context->tokenOptions($token);
switch($token) {
switch($context->tokenName($token)) {
case 'echo':
case 'print':
if (in_array('raw', $opt)) {
return "<?php echo $arguments ?>";
}
return "<?php echo htmlspecialchars((string) $arguments, {$this->flag}, '{$this->encoding}', " . ($this->doubleEncode ? "true" : "false") . ") ?>";
case 'echo.raw':
case "print.raw":
return "<?php echo $arguments ?>";
case 'printf':
return "<?php echo htmlspecialchars(sprintf((string) $arguments), {$this->flag}, '{$this->encoding}', " . ($this->doubleEncode ? "true" : "false") . ") ?>";
case 'printf.raw':
if (in_array('raw', $opt)) {
return "<?php printf((string) $arguments) ?>";
}
return "<?php echo htmlspecialchars(sprintf((string) $arguments), {$this->flag}, '{$this->encoding}', " . ($this->doubleEncode ? "true" : "false") . ") ?>";
}
}
}