Sha256: ef4054d75b133717da8516c4a140e5419587496ca5f44f0660fa6168b678d9b2
Contents?: true
Size: 793 Bytes
Versions: 2
Compression:
Stored size: 793 Bytes
Contents
class JbuilderTemplate < Jbuilder def initialize(context, *args) @context = context super(*args) end def partial!(options, locals = {}) case options when ::Hash options[:locals] ||= {} options[:locals].merge!(:json => self) @context.render(options) else @context.render(options, locals.merge(:json => self)) end end end class JbuilderHandler cattr_accessor :default_format self.default_format = Mime::JSON def self.call(template) # this juggling is required to keep line numbers right in the error %{__already_defined = defined?(json); json||=JbuilderTemplate.new(self); #{template.source} json.target! unless __already_defined} end end ActionView::Template.register_template_handler :jbuilder, JbuilderHandler
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
jbuilder-0.7.0 | ./lib/jbuilder_template.rb |
jbuilder-0.6.0 | ./lib/jbuilder_template.rb |