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-10-06 16:51:34 -07:00

31 lines
No EOL
756 B
Ruby

require "yui/compressor"
module Middleman
module Minified
module Javascript
include ::Haml::Filters::Base
def render_with_options(text, options)
compressor = ::YUI::JavaScriptCompressor.new(:munge => true)
data = compressor.compress(text)
<<END
<script type=#{options[:attr_wrapper]}text/javascript#{options[:attr_wrapper]}>#{data.chomp}</script>
END
end
end
module StaticJavascript
def render_path(path)
if template_exists?(path, :js)
compressor = YUI::JavaScriptCompressor.new(:munge => true)
compressor.compress(super)
else
super
end
end
end
end
class Base
include Middleman::Minified::StaticJavascript
end
end