File tree Expand file tree Collapse file tree 2 files changed +12
-2
lines changed Expand file tree Collapse file tree 2 files changed +12
-2
lines changed Original file line number Diff line number Diff line change @@ -1067,6 +1067,16 @@ public function testScriptBlock() {
1067
1067
);
1068
1068
$ this ->assertTags ($ result , $ expected );
1069
1069
1070
+ $ result = $ this ->Html ->scriptBlock ('window.foo = 2; ' , array ('type ' => 'text/x-handlebars-template ' ));
1071
+ $ expected = array (
1072
+ 'script ' => array ('type ' => 'text/x-handlebars-template ' ),
1073
+ $ this ->cDataStart ,
1074
+ 'window.foo = 2; ' ,
1075
+ $ this ->cDataEnd ,
1076
+ '/script ' ,
1077
+ );
1078
+ $ this ->assertTags ($ result , $ expected );
1079
+
1070
1080
$ result = $ this ->Html ->scriptBlock ('window.foo = 2; ' , array ('safe ' => false ));
1071
1081
$ expected = array (
1072
1082
'script ' => array ('type ' => 'text/javascript ' ),
Original file line number Diff line number Diff line change @@ -98,7 +98,7 @@ class HtmlHelper extends AppHelper {
98
98
'ol ' => '<ol%s>%s</ol> ' ,
99
99
'li ' => '<li%s>%s</li> ' ,
100
100
'error ' => '<div%s>%s</div> ' ,
101
- 'javascriptblock ' => '<script type="text/javascript" %s>%s</script> ' ,
101
+ 'javascriptblock ' => '<script%s>%s</script> ' ,
102
102
'javascriptstart ' => '<script type="text/javascript"> ' ,
103
103
'javascriptlink ' => '<script type="text/javascript" src="%s"%s></script> ' ,
104
104
'javascriptend ' => '</script> '
@@ -560,7 +560,7 @@ public function script($url, $options = array()) {
560
560
* @link http://book.cakephp.org/2.0/en/core-libraries/helpers/html.html#HtmlHelper::scriptBlock
561
561
*/
562
562
public function scriptBlock ($ script , $ options = array ()) {
563
- $ options += array ('safe ' => true , 'inline ' => true );
563
+ $ options += array ('type ' => ' text/javascript ' , ' safe ' => true , 'inline ' => true );
564
564
if ($ options ['safe ' ]) {
565
565
$ script = "\n" . '//<![CDATA[ ' . "\n" . $ script . "\n" . '//]]> ' . "\n" ;
566
566
}
You can’t perform that action at this time.
0 commit comments