Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bogdanRada/90149a91e0dcb7bc76eb to your computer and use it in GitHub Desktop.
Save bogdanRada/90149a91e0dcb7bc76eb 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