Skip to content

Instantly share code, notes, and snippets.

@tenderlove
Created June 21, 2009 05:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save tenderlove/133413 to your computer and use it in GitHub Desktop.
Save tenderlove/133413 to your computer and use it in GitHub Desktop.
require 'nokogiri'
module ActionView
module TemplateHandlers
class Nokogiri < TemplateHandler
include Compilable
def compile template
<<-eotemplate
_set_controller_content_type(Mime::XML)
builder = ::Nokogiri::XML::Builder.new do |xml|
#{template.source}
end
builder.to_xml
eotemplate
end
end
end
end
ActionView::Template.register_template_handler :nokogiri,
ActionView::TemplateHandlers::Nokogiri
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment