1
0
Fork 0
mirror of https://github.com/middleman/middleman.git synced 2022-11-09 12:20:27 -05:00
middleman--middleman/lib/middleman/features/minify_javascript.rb
2009-12-29 21:00:16 -08:00

22 lines
No EOL
690 B
Ruby
Executable file

module Middleman
module Minified
module Javascript
include ::Haml::Filters::Base
def render_with_options(text, options)
if Middleman::Base.respond_to?(:minify_javascript?) && Middleman::Base.minify_javascript?
compressor = ::YUI::JavaScriptCompressor.new(:munge => true)
data = compressor.compress(text)
%Q{<script type=#{options[:attr_wrapper]}text/javascript#{options[:attr_wrapper]}>#{data.chomp}</script>}
else
<<END
<script type=#{options[:attr_wrapper]}text/javascript#{options[:attr_wrapper]}>
//<![CDATA[
#{text.rstrip.gsub("\n", "\n ")}
//]]>
</script>
END
end
end
end
end
end