- Token name and options are now passed through parse() method
This commit is contained in:
1 parent
e9b2f0ece3
commit
b3a8e3aca2
29 files changed
+70
-59
No files matched your search
@@ -18,21 +18,19 @@ class PrintExtension implements Extension {
|
||||
$this->encoding = ini_get("default_charset");
|
||||
}
|
||||
|
||||
public function parse(\Picea\Compiler\Context &$context, ?string $arguments, string $token) : string
|
||||
public function parse(\Picea\Compiler\Context &$context, ?string $arguments, string $token, array $options = []) : string
|
||||
{
|
||||
$opt = $context->tokenOptions($token);
|
||||
|
||||
switch($context->tokenName($token)) {
|
||||
switch($token) {
|
||||
case 'echo':
|
||||
case 'print':
|
||||
if (in_array('raw', $opt)) {
|
||||
if (in_array('raw', $options)) {
|
||||
return "<?php echo $arguments ?>";
|
||||
}
|
||||
|
||||
return "<?php echo htmlspecialchars((string) $arguments, {$this->flag}, '{$this->encoding}', " . ($this->doubleEncode ? "true" : "false") . ") ?>";
|
||||
|
||||
case 'printf':
|
||||
if (in_array('raw', $opt)) {
|
||||
if (in_array('raw', $options)) {
|
||||
return "<?php printf((string) $arguments) ?>";
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user