2009-10-22 20:25:15 -04:00
|
|
|
module Middleman
|
|
|
|
module Minified
|
|
|
|
module Javascript
|
|
|
|
include ::Haml::Filters::Base
|
|
|
|
def render_with_options(text, options)
|
2009-11-22 18:37:11 -05:00
|
|
|
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>
|
2009-10-22 20:25:15 -04:00
|
|
|
END
|
2009-11-22 18:37:11 -05:00
|
|
|
end
|
2009-10-22 20:25:15 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2009-11-22 18:37:11 -05:00
|
|
|
end
|