Skip to content

Commit

Permalink
Clean up new batch functionality in escaping functions.
Browse files Browse the repository at this point in the history
  • Loading branch information
reinink committed Oct 21, 2014
1 parent 10ce61b commit c39d8fb
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
16 changes: 8 additions & 8 deletions src/Template/Template.php
Original file line number Diff line number Diff line change
Expand Up @@ -263,28 +263,28 @@ protected function batch($var, $functions)

/**
* Escape string.
* @param string $string
* @param string $string
* @param null|string $functions
* @return string
*/
protected function escape($string)
protected function escape($string, $functions = null)
{
$functions = array_slice(func_get_args(), 1);

if ($functions) {
$string = $this->batch($string, implode('|', $functions));
$string = $this->batch($string, $functions);
}

return htmlspecialchars($string, ENT_QUOTES | ENT_SUBSTITUTE, 'UTF-8');
}

/**
* Alias to escape function.
* @param string $string
* @param string $string
* @param null|string $functions
* @return string
*/
protected function e($string)
protected function e($string, $functions = null)
{
return call_user_func_array(array($this, 'escape'), func_get_args());
return $this->escape($string, $functions);
}
}

Expand Down
2 changes: 1 addition & 1 deletion tests/Template/TemplateTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ public function testEscapeFunctionBatch()
{
vfsStream::create(
array(
'template.php' => '<?php echo $this->escape("<strong>Jonathan</strong>", "strtoupper", "strrev") ?>'
'template.php' => '<?php echo $this->escape("<strong>Jonathan</strong>", "strtoupper|strrev") ?>'
)
);

Expand Down

0 comments on commit c39d8fb

Please sign in to comment.