Skip to content

Instantly share code, notes, and snippets.

@pdamer
Forked from tenderlove/nokogiri_template_handler.rb
Last active December 16, 2015 01:29
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 pdamer/5355811 to your computer and use it in GitHub Desktop.
Save pdamer/5355811 to your computer and use it in GitHub Desktop.
module ActionView
module Template::Handlers
class Nokogiri
# Default format used by Builder.
class_attribute :default_format
self.default_format = Mime::XML
def call template
require 'nokogiri'
<<-eotemplate
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::Template::Handlers::Nokogiri.new
@pdamer
Copy link
Author

pdamer commented Apr 10, 2013

updated for rails 3.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment