lib/jammit/compressor.rb in jammit-0.4.0 vs lib/jammit/compressor.rb in jammit-0.4.1

- old
+ new

@@ -59,17 +59,13 @@ @options = DEFAULT_OPTIONS[flavor].merge(Jammit.compressor_options || {}) @js_compressor = COMPRESSORS[flavor].new(@options) end # Concatenate together a list of JavaScript paths, and pass them through the - # YUI Compressor (with munging enabled). JST can optionally be included. + # YUI Compressor (with munging enabled). def compress_js(paths) - if (jst_paths = paths.grep(JST_EXT)).empty? - js = concatenate(paths) - else - js = concatenate(paths - jst_paths) + compile_jst(jst_paths) - end + js = concatenate(paths) Jammit.compress_assets ? @js_compressor.compress(js) : js end # Concatenate and compress a list of CSS stylesheets. When compressing a # :datauri or :mhtml variant, post-processes the result to embed @@ -90,10 +86,10 @@ # JST-compilation function to the top of the package, unless you've # specified your own preferred function, or turned it off. # JST templates are named with the basename of their file. def compile_jst(paths) namespace = Jammit.template_namespace - compiled = paths.grep(JST_EXT).map do |path| + compiled = paths.map do |path| template_name = File.basename(path, File.extname(path)) contents = File.read(path).gsub(/\n/, '').gsub("'", '\\\\\'') "#{namespace}.#{template_name} = #{Jammit.template_function}('#{contents}');" end compiler = Jammit.include_jst_script ? File.read(DEFAULT_JST_SCRIPT) : '';