- First commit of first draft
This commit is contained in:
commit
66c7b349d1
36 files changed
+820
No files matched your search
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace Picea\Syntax;
|
||||
|
||||
class EchoSafeToken implements Syntax {
|
||||
|
||||
public string $tokenOpen = "\{\{";
|
||||
|
||||
public string $tokenClose = "\}\}";
|
||||
|
||||
public int $flag = \ENT_QUOTES;
|
||||
|
||||
public string $encoding;
|
||||
|
||||
public bool $doubleEncode = true;
|
||||
|
||||
public function __construct() {
|
||||
$this->encoding = ini_get("default_charset");
|
||||
}
|
||||
|
||||
public function parse(/*\Picae\Compiler\Context*/ &$context, string &$sourceCode)
|
||||
{
|
||||
$sourceCode = preg_replace_callback("#({$this->tokenOpen})(.*?)({$this->tokenClose})#s", function ($matches) {
|
||||
return "<?php echo htmlspecialchars({$matches[2]}, {$this->flag}, '{$this->encoding}', " . ($this->doubleEncode ? "true" : "false") . ") ?>";
|
||||
}, $sourceCode);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user