mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-19 11:06:15 +00:00
Allow setting different type on scriptBlock
This commit is contained in:
parent
28a3b73bdc
commit
f19615a3be
2 changed files with 12 additions and 2 deletions
|
@ -1067,6 +1067,16 @@ class HtmlHelperTest extends CakeTestCase {
|
||||||
);
|
);
|
||||||
$this->assertTags($result, $expected);
|
$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));
|
$result = $this->Html->scriptBlock('window.foo = 2;', array('safe' => false));
|
||||||
$expected = array(
|
$expected = array(
|
||||||
'script' => array('type' => 'text/javascript'),
|
'script' => array('type' => 'text/javascript'),
|
||||||
|
|
|
@ -98,7 +98,7 @@ class HtmlHelper extends AppHelper {
|
||||||
'ol' => '<ol%s>%s</ol>',
|
'ol' => '<ol%s>%s</ol>',
|
||||||
'li' => '<li%s>%s</li>',
|
'li' => '<li%s>%s</li>',
|
||||||
'error' => '<div%s>%s</div>',
|
'error' => '<div%s>%s</div>',
|
||||||
'javascriptblock' => '<script type="text/javascript"%s>%s</script>',
|
'javascriptblock' => '<script%s>%s</script>',
|
||||||
'javascriptstart' => '<script type="text/javascript">',
|
'javascriptstart' => '<script type="text/javascript">',
|
||||||
'javascriptlink' => '<script type="text/javascript" src="%s"%s></script>',
|
'javascriptlink' => '<script type="text/javascript" src="%s"%s></script>',
|
||||||
'javascriptend' => '</script>'
|
'javascriptend' => '</script>'
|
||||||
|
@ -560,7 +560,7 @@ class HtmlHelper extends AppHelper {
|
||||||
* @link http://book.cakephp.org/2.0/en/core-libraries/helpers/html.html#HtmlHelper::scriptBlock
|
* @link http://book.cakephp.org/2.0/en/core-libraries/helpers/html.html#HtmlHelper::scriptBlock
|
||||||
*/
|
*/
|
||||||
public function scriptBlock($script, $options = array()) {
|
public function scriptBlock($script, $options = array()) {
|
||||||
$options += array('safe' => true, 'inline' => true);
|
$options += array('type' => 'text/javascript', 'safe' => true, 'inline' => true);
|
||||||
if ($options['safe']) {
|
if ($options['safe']) {
|
||||||
$script = "\n" . '//<![CDATA[' . "\n" . $script . "\n" . '//]]>' . "\n";
|
$script = "\n" . '//<![CDATA[' . "\n" . $script . "\n" . '//]]>' . "\n";
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue