Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Allow setting different type on scriptBlock

  • Loading branch information...
commit f19615a3be54dbf994908d758974a040887bd25d 1 parent 28a3b73
@gilleswittenberg gilleswittenberg authored
View
10 lib/Cake/Test/Case/View/Helper/HtmlHelperTest.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'),
View
4 lib/Cake/View/Helper/HtmlHelper.php
@@ -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";
}
Please sign in to comment.
Something went wrong with that request. Please try again.