lib/ahcx_template_handler.rb in ahc-0.2.0 vs lib/ahcx_template_handler.rb in ahc-0.2.1
- old
+ new
@@ -3,17 +3,11 @@
class AhcxTemplateHandler
def self.call(template)
erb = ActionView::Template.registered_template_handler(:erb)
source = erb.call(template)
- ahcx_source = "<document>#{eval(source)}</document>"
- ahcx = Nokogiri.parse(ahcx_source)
- content = ''
- ahcx.children.first.children.each do |node|
- content += node_content(node)
- end
- content.inspect
+ source + ";AhcxTemplateHandler.render(@output_buffer.to_s)"
end
def self.node_content(node)
tag = node.name
params = {}
@@ -34,7 +28,16 @@
end
end
Ahc.render(tag, params)
end
-end
+ def self.render(xml)
+ ahcx_source = "<document>#{xml}</document>"
+ ahcx = Nokogiri.parse(ahcx_source)
+ content = ''
+ ahcx.children.first.children.each do |node|
+ content += node_content(node)
+ end
+ content
+ end
+end