Skip to content
Permalink
Browse files

Allow setting different type on scriptBlock

  • Loading branch information...
gilleswittenberg committed May 18, 2013
1 parent 28a3b73 commit f19615a3be54dbf994908d758974a040887bd25d
Showing with 12 additions and 2 deletions.
  1. +10 −0 lib/Cake/Test/Case/View/Helper/HtmlHelperTest.php
  2. +2 −2 lib/Cake/View/Helper/HtmlHelper.php
@@ -1067,6 +1067,16 @@ public function testScriptBlock() {
);
$this->assertTags($result, $expected);
$result = $this->Html->scriptBlock('window.foo = 2;', array('type' => 'text/x-handlebars-template'));
$expected = array(
'script' => array('type' => 'text/x-handlebars-template'),
$this->cDataStart,
'window.foo = 2;',
$this->cDataEnd,
'/script',
);
$this->assertTags($result, $expected);
$result = $this->Html->scriptBlock('window.foo = 2;', array('safe' => false));
$expected = array(
'script' => array('type' => 'text/javascript'),
@@ -98,7 +98,7 @@ class HtmlHelper extends AppHelper {
'ol' => '<ol%s>%s</ol>',
'li' => '<li%s>%s</li>',
'error' => '<div%s>%s</div>',
'javascriptblock' => '<script type="text/javascript"%s>%s</script>',
'javascriptblock' => '<script%s>%s</script>',
'javascriptstart' => '<script type="text/javascript">',
'javascriptlink' => '<script type="text/javascript" src="%s"%s></script>',
'javascriptend' => '</script>'
@@ -560,7 +560,7 @@ public function script($url, $options = array()) {
* @link http://book.cakephp.org/2.0/en/core-libraries/helpers/html.html#HtmlHelper::scriptBlock
*/
public function scriptBlock($script, $options = array()) {
$options += array('safe' => true, 'inline' => true);
$options += array('type' => 'text/javascript', 'safe' => true, 'inline' => true);
if ($options['safe']) {
$script = "\n" . '//<![CDATA[' . "\n" . $script . "\n" . '//]]>' . "\n";
}

0 comments on commit f19615a

Please sign in to comment.
You can’t perform that action at this time.