Skip to content

Instantly share code, notes, and snippets.

@ajsharp
Created April 10, 2013 03:24
Show Gist options
  • Select an option

  • Save ajsharp/5351517 to your computer and use it in GitHub Desktop.

Select an option

Save ajsharp/5351517 to your computer and use it in GitHub Desktop.
module ActionView::Template::Handlers
class Bldr
# @return [String] the rendered template string
def self.call(template, opts = {})
source = if template.source.empty?
File.read(template.identifier)
else
template.source
end
%{
node = ::Bldr::Node.new(nil, parent: self) {
#{source}
}
MultiJson.encode node.result
}
end
end
end
ActionView::Template.register_template_handler :bldr, ActionView::Template::Handlers::Bldr
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment