Created
October 19, 2011 04:11
-
-
Save willrjmarshall/1297460 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Rails 3.X Template | |
if defined?(Rails) && Rails.version =~ /^3/ | |
module ActionView | |
module Template::Handlers | |
class Rabl | |
class_attribute :default_format | |
self.default_format = Mime::JSON | |
def self.call(template) | |
source = if template.source.empty? | |
File.read(template.identifier) | |
else # use source | |
template.source | |
end | |
%{ ::Rabl::Engine.new(#{source.inspect}, { :format => "json"}). | |
render(self, assigns.merge(local_assigns)) } | |
end # call | |
end # rabl class | |
end # handlers | |
end | |
ActionView::Template.register_template_handler :rabl, ActionView::Template::Handlers::Rabl | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment