lib/prez/assets.rb in prez-0.0.1 vs lib/prez/assets.rb in prez-0.0.2

- old
+ new

@@ -1,17 +1,20 @@ +require "coffee-script" require "prez/files" +require "prez/sass_extensions" require "sass" require "uglifier" module Prez module Assets class Tagged - attr_reader :name, :contents + attr_reader :name, :contents, :file def initialize(name, options = {}) @name = name @contents = Prez::Files.contents name, extension + @file = Prez::Files.find name, extension @dev = options.fetch :dev, false end def dev? @dev @@ -27,11 +30,11 @@ def to_tag if dev? "#{open}\n#{contents}#{close}" else - "#{open}#{minified_contents}#{close}" + "#{open}#{minified_contents.strip}#{close}" end end end class Javascript < Prez::Assets::Tagged @@ -46,10 +49,11 @@ def close %{</script>} end def minify(contents) + contents = CoffeeScript.compile contents if file =~ /\.coffee$/ Uglifier.compile contents end end class Stylesheet < Prez::Assets::Tagged @@ -64,10 +68,13 @@ def close %{</style>} end def minify(contents) - Sass::Engine.new(contents, syntax: :scss, style: :compressed).render + Sass::Engine.new(contents, + syntax: :scss, + style: :compressed, + load_paths: [File.expand_path("..", file)]).render end end class << self def javascript(name, options = {})