diff --git a/src/Handlebars/Handlebars.php b/src/Handlebars/Handlebars.php index 7472f42..4c4f518 100755 --- a/src/Handlebars/Handlebars.php +++ b/src/Handlebars/Handlebars.php @@ -50,16 +50,6 @@ public static function factory(array $options = []): Handlebars private Loader $partialsLoader; - /** - * @var callable escape function to use - */ - private $escape = 'htmlspecialchars'; - - /** - * @var array parameters to pass to escape function - */ - private array $escapeArgs = [ENT_COMPAT, 'UTF-8']; - private array $aliases = []; /** @@ -71,8 +61,6 @@ public static function factory(array $options = []): Handlebars * Handlebars engine constructor * $options array can contain : * helpers => Helpers object - * escape => a callable function to escape values - * escapeArgs => array to pass as extra parameter to escape function * loader => Loader object * partials_loader => Loader object * enableDataVariables => boolean. Enables @data variables (default: false) @@ -95,22 +83,6 @@ public function __construct(Array $options = []) $this->setPartialsLoader($options['partials_loader']); } - if (isset($options['escape'])) { - if (!is_callable($options['escape'])) { - throw new InvalidArgumentException( - 'Handlebars Constructor "escape" option must be callable' - ); - } - $this->escape = $options['escape']; - } - - if (isset($options['escapeArgs'])) { - if (!is_array($options['escapeArgs'])) { - $options['escapeArgs'] = array($options['escapeArgs']); - } - $this->escapeArgs = $options['escapeArgs']; - } - if (isset($options['partials_alias']) && is_array($options['partials_alias']) ) { @@ -238,46 +210,6 @@ public function getPartialsLoader(): Loader return $this->partialsLoader; } - /** - * Get current escape function - */ - public function getEscape(): callable - { - return $this->escape; - } - - /** - * Set current escape function - * @throws \InvalidArgumentException - */ - public function setEscape(callable $escape): void - { - if (!is_callable($escape)) { - throw new InvalidArgumentException( - 'Escape function must be a callable' - ); - } - $this->escape = $escape; - } - - /** - * Get current escape function - */ - public function getEscapeArgs(): array - { - return $this->escapeArgs; - } - - /** - * Set current escape function - * - * @param array $escapeArgs arguments to pass as extra arg to function - */ - public function setEscapeArgs(array $escapeArgs): void - { - $this->escapeArgs = $escapeArgs; - } - /** * Set the Handlebars Tokenizer instance. */ diff --git a/src/Handlebars/Template.php b/src/Handlebars/Template.php index 340e439..4c7379d 100755 --- a/src/Handlebars/Template.php +++ b/src/Handlebars/Template.php @@ -305,12 +305,7 @@ private function variables(Context $context, array $current, bool $escaped): str } if ($escaped) { - $args = $this->handlebars->getEscapeArgs(); - array_unshift($args, $value); - $value = call_user_func_array( - $this->handlebars->getEscape(), - array_values($args) - ); + $value = htmlspecialchars($value, ENT_COMPAT, 'UTF-8'); } return $value;