Skip to content

Commit

Permalink
Deprecating $escape for HtmlHelper::tag() use $attributes['escape'] i…
Browse files Browse the repository at this point in the history
…nstead. Test case added.
  • Loading branch information
markstory committed Aug 27, 2009
1 parent 56d2423 commit 136b4db
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 13 deletions.
5 changes: 4 additions & 1 deletion cake/libs/view/helpers/html.php
Expand Up @@ -708,7 +708,10 @@ function tableCells($data, $oddTrOptions = null, $evenTrOptions = null, $useCoun
* @access public
*/
function tag($name, $text = null, $attributes = array(), $escape = false) {
if ($escape) {
if ($escape || isset($attributes['escape']) && $attributes['escape']) {
if (is_array($attributes)) {
unset($attributes['escape']);
}
$text = h($text);
}
if (!is_array($attributes)) {
Expand Down
18 changes: 6 additions & 12 deletions cake/tests/cases/libs/view/helpers/html.test.php
Expand Up @@ -123,16 +123,17 @@ function startTest() {
}

/**
* tearDown method
* endTest method
*
* @access public
* @return void
*/
function tearDown() {
function endTest() {
Configure::write('App.encoding', $this->_appEncoding);
Configure::write('Asset', $this->_asset);
Configure::write('debug', $this->_debug);
ClassRegistry::flush();
unset($this->Html);
}

/**
Expand Down Expand Up @@ -1108,6 +1109,9 @@ function testTag() {
$result = $this->Html->tag('div', '<text>', array('class' => 'class-name'), true);
$this->assertTags($result, array('div' => array('class' => 'class-name'), '&lt;text&gt;', '/div'));

$result = $this->Html->tag('div', '<text>', array('class' => 'class-name', 'escape' => true));
$this->assertTags($result, array('div' => array('class' => 'class-name'), '&lt;text&gt;', '/div'));

$result = $this->Html->tag('div', '<text>', 'class-name', true);
$this->assertTags($result, array('div' => array('class' => 'class-name'), '&lt;text&gt;', '/div'));
}
Expand Down Expand Up @@ -1145,15 +1149,5 @@ function testPara() {
$result = $this->Html->para('class-name', '<text>', array(), true);
$this->assertTags($result, array('p' => array('class' => 'class-name'), '&lt;text&gt;', '/p'));
}
/**
* endTest method
*
* @access public
* @return void
*/
function endTest() {
ClassRegistry::flush();
unset($this->Html);
}
}
?>

0 comments on commit 136b4db

Please sign in to comment.