lib/htmlcompressor/compressor.rb in htmlcompressor-0.1.2 vs lib/htmlcompressor/compressor.rb in htmlcompressor-0.2.0

- old
+ new

@@ -126,19 +126,32 @@ :remove_http_protocol => false, :remove_https_protocol => false, :preserve_line_breaks => false, :remove_surrounding_spaces => nil, - :preserve_patterns => nil, - :javascript_compressor => nil, - :css_compressor => nil + :preserve_patterns => nil } def initialize(options = {}) @options = DEFAULT_OPTIONS.merge(options) + if @options[:compress_js_templates] + @options[:remove_quotes] = false + + js_template_types = [ 'text/x-jquery-tmpl' ] + + unless @options[:compress_js_templates].is_a? TrueClass + js_template_types << @options[:compress_js_templates] + js_template_types.flatten! + end + + @options[:js_template_types] = js_template_types + else + @options[:js_template_types] = [] + end + detect_external_compressors end def detect_external_compressors @javascript_compressors = {} @@ -312,10 +325,10 @@ if type.length == 0 or type == 'text/javascript' or type == 'application/javascript' # javascript block, preserve and compress with js compressor scriptBlocks << group_2 index += 1 group_1 + message_format(TEMP_SCRIPT_BLOCK, index) + group_3 - elsif type == 'text/x-jquery-tmpl' + elsif @options[:js_template_types].include?(type) # jquery template, ignore so it gets compressed with the rest of html match else # some custom script, preserve it inside "skip blocks" so it won't be compressed with js compressor skipBlocks << group_2