lib/ahcx_template_handler.rb in ahc-0.2.2 vs lib/ahcx_template_handler.rb in ahc-0.2.4
- old
+ new
@@ -1,6 +1,7 @@
require 'nokogiri'
+require 'htmlcompressor'
class AhcxTemplateHandler
def self.call(template)
erb = ActionView::Template.registered_template_handler(:erb)
@@ -16,11 +17,11 @@
end
node.children.each do |child_node|
child_node_tag, child_node_attr = child_node.name.split(':')
raw = child_node.attributes['raw']
if raw || (child_node.children.length == 1 && child_node.children.first.name == 'text')
- params[child_node_attr] = child_node.children.to_s
+ params[child_node_attr] = child_node.children.to_html(:encoding => 'utf-8')
else
attr_value = ''
child_node.children.each do |inside_node|
attr_value += node_content(inside_node)
end
@@ -35,9 +36,10 @@
ahcx = Nokogiri.parse(ahcx_source)
content = ''
ahcx.children.first.children.each do |node|
content += node_content(node)
end
- content
+ compressor = HtmlCompressor::Compressor.new(:remove_intertag_spaces => true)
+ compressor.compress(content)
end
end