Skip to content
Browse files

seperate js/css for debug. Thanks ryonp! (https://github.com/mcurry/a…

  • Loading branch information...
1 parent ca875ea commit 9828d3d796a091e0ce46ce2dddcf1784ffe98ac9 Matt Curry committed Mar 4, 2011
Showing with 21 additions and 3 deletions.
  1. +21 −3 views/helpers/asset.php
View
24 views/helpers/asset.php
@@ -85,9 +85,27 @@ function scripts_for_layout($types=array('js', 'css', 'codeblock')) {
$this->__init();
}
- if (Configure::read('debug') && $this->options['debug'] == false) {
- return join("\n\t", $this->View->__scripts);
- }
+ //Allow breaking up of js,css,codeblock in your html when debug is > 0
+ //Ex: putting 'css' in head and 'js','codeblock' at bottom before </body>
+ if (Configure::read('debug') && $this->options['debug'] == false) {
+ $scripts_for_layout = array();
+
+ foreach ($this->View->__scripts as $resource) {
+ foreach ($types as $type) {
+ if($type == 'css' || $type == 'js') {
+ if(stristr($resource, '.'.$type)) {
+ $scripts_for_layout[] = $resource;
+ }
+ } else if($type == 'codeblock') {
+ if(!stristr($resource, '.js') && !stristr($resource,' .css')) {
+ $scripts_for_layout[] = $resource;
+ }
+ }
+ }
+ }
+
+ return join("\n\t", $scripts_for_layout);
+ }
$scripts_for_layout = array();
foreach($this->assets as $asset) {

0 comments on commit 9828d3d

Please sign in to comment.
Something went wrong with that request. Please try again.