Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Added in development switch

  • Loading branch information...
commit c8953f46cf9ee25941d49757c82e5661d3f8a31d 1 parent ff886e4
@alexgisby authored
View
40 classes/assets/html.php
@@ -35,9 +35,16 @@ class Assets_HTML extends Kohana_HTML
*/
public static function style($file, array $attributes = NULL, $protocol = NULL, $index = FALSE)
{
- self::construct_assets();
- self::$_assets->add($file);
- // return parent::style($file, $attributes, $protocol, $index);
+ if(Assets::will_compile())
+ {
+ self::construct_assets();
+ self::$_assets->add($file);
+ return '';
+ }
+ else
+ {
+ return parent::style($file, $attributes, $protocol, $index);
+ }
}
/**
@@ -57,9 +64,15 @@ public static function style($file, array $attributes = NULL, $protocol = NULL,
*/
public static function script($file, array $attributes = NULL, $protocol = NULL, $index = FALSE)
{
- self::construct_assets();
- self::$_assets->add($file);
- // return parent::script($file, $attributes, $protocol, $index);
+ if(Assets::will_compile())
+ {
+ self::construct_assets();
+ self::$_assets->add($file);
+ }
+ else
+ {
+ return parent::script($file, $attributes, $protocol, $index);
+ }
}
/**
@@ -69,7 +82,12 @@ public static function script($file, array $attributes = NULL, $protocol = NULL,
*/
public static function compiled_css()
{
- return parent::style(self::$_assets->url_for_asset(self::$_assets->compile_css()));
+ if(Assets::will_compile())
+ {
+ return parent::style(self::$_assets->url_for_asset(self::$_assets->compile_css()));
+ }
+
+ return '';
}
/**
@@ -79,8 +97,12 @@ public static function compiled_css()
*/
public static function compiled_js()
{
- return parent::script(self::$_assets->url_for_asset(self::$_assets->compile_js()));
- // return self::$_assets->compile_js();
+ if(Assets::will_compile())
+ {
+ return parent::script(self::$_assets->url_for_asset(self::$_assets->compile_js()));
+ }
+
+ return '';
}
/**
View
25 classes/kohana/assets.php
@@ -71,6 +71,23 @@ public function add($file)
}
/**
+ * Whether the assets will be compiled down or not.
+ * If you're on dev, it won't compile (unless you set the config compile_on_dev as true)
+ * Everywhere else it will.
+ *
+ * @return bool
+ */
+ public static function will_compile()
+ {
+ if(kohana::$environment == kohana::DEVELOPMENT)
+ {
+ return kohana::$config->load('assets.compile_on_dev');
+ }
+
+ return true;
+ }
+
+ /**
* Compile the CSS files and return the filename of the output.
*
* @param array Options for the compiler. Overrides those in the config file.
@@ -144,14 +161,6 @@ public function compile_js(array $options = array())
}
return $filename;
-
-
- // $compiler_class = 'Compiler_' . $this->config->css['compiler'];
- // $compiler = new $compiler_class();
- //
- // $compiler->add_files($this->js);
- //
- // return sha1(time()) . '.min.js';
}
View
5 config/assets.php
@@ -46,6 +46,11 @@
),
),
+ /**
+ * Compile on dev or not.
+ * Generally speaking, you won't want to compile on dev all the time, so leave this false.
+ */
+ 'compile_on_dev' => false,
/**
* Path to YUI compressor within a vendor/ folder.
Please sign in to comment.
Something went wrong with that request. Please try again.