Skip to content

Commit

Permalink
Merge pull request #1292 from openam/HtmlHelper
Browse files Browse the repository at this point in the history
make HtmlHelper::tag() just return the $text content with no wrapping tag when $name === false
  • Loading branch information
markstory committed May 21, 2013
2 parents e2304d8 + 0d082b5 commit 28a3b73
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
9 changes: 9 additions & 0 deletions lib/Cake/Test/Case/View/Helper/HtmlHelperTest.php
Expand Up @@ -1694,6 +1694,15 @@ public function testTag() {

$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(false, '<em>stuff</em>');
$this->assertEquals($result, '<em>stuff</em>');

$result = $this->Html->tag(null, '<em>stuff</em>');
$this->assertEquals($result, '<em>stuff</em>');

$result = $this->Html->tag('', '<em>stuff</em>');
$this->assertEquals($result, '<em>stuff</em>');
}

/**
Expand Down
3 changes: 3 additions & 0 deletions lib/Cake/View/Helper/HtmlHelper.php
Expand Up @@ -896,6 +896,9 @@ public function tableCells($data, $oddTrOptions = null, $evenTrOptions = null, $
* @link http://book.cakephp.org/2.0/en/core-libraries/helpers/html.html#HtmlHelper::tag
*/
public function tag($name, $text = null, $options = array()) {
if (empty($name)) {
return $text;
}
if (is_array($options) && isset($options['escape']) && $options['escape']) {
$text = h($text);
unset($options['escape']);
Expand Down

0 comments on commit 28a3b73

Please sign in to comment.