Skip to content

Commit

Permalink
Adding Backwards compatibility for $scripts_for_layout.
Browse files Browse the repository at this point in the history
  • Loading branch information
markstory committed Dec 18, 2011
1 parent 4606ea3 commit 6d425df
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions lib/Cake/View/View.php
Expand Up @@ -396,7 +396,10 @@ public function render($view = null, $layout = null) {
*
* - `title_for_layout` - A backwards compatible place holder, you should set this value if you want more control.
* - `content_for_layout` - contains rendered view file
* - `scripts_for_layout` - contains scripts added to header
* - `scripts_for_layout` - Contains content added with addScript() as well as any content in
* the 'meta', 'css', and 'script' blocks. They are appended in that order.
*
* `$scripts_for_layout` is deprecated and will be removed in CakePHP 3.0
*
* @param string $content_for_layout Content to render in a view, wrapped by the surrounding layout.
* @param string $layout Layout name
Expand All @@ -413,9 +416,12 @@ public function renderLayout($content_for_layout, $layout = null) {
}
$this->Helpers->trigger('beforeLayout', array($layoutFileName));

$scripts = implode("\n\t", $this->_scripts);
$scripts .= $this->get('meta') . $this->get('css') . $this->get('script');

$this->viewVars = array_merge($this->viewVars, array(
'content_for_layout' => $content_for_layout,
'scripts_for_layout' => implode("\n\t", $this->_scripts),
'scripts_for_layout' => $scripts,
));

if (!isset($this->viewVars['title_for_layout'])) {
Expand Down

0 comments on commit 6d425df

Please sign in to comment.