require 'action_view/base' require 'action_view/template' module ActionView module Template::Handlers class ArgonautBuilder < Template::Handler include Compilable self.default_format = Mime::JSON def compile(template) "doc = ::Argonaut::Generator.new do |json|" + template.source + "end;doc.to_json;" end end end end ActionView::Template.register_template_handler :json_builder, ActionView::Template::Handlers::ArgonautBuilder