Skip to content

Commit

Permalink
fix 2 level partial bug
Browse files Browse the repository at this point in the history
  • Loading branch information
nazipov committed Sep 22, 2015
1 parent e72fba2 commit 403e2a9
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions lib/tilt/jbuilder.rb
Expand Up @@ -22,8 +22,8 @@ def partial!(name_or_options, locals = {})
end

view_path = @scope.instance_variable_get('@_jbuilder_view_path')
@template = ::Tilt::JbuilderTemplate.new(fetch_partial_path(options[:partial].to_s, view_path), nil, view_path: view_path)
render_partial_with_options options
template = ::Tilt::JbuilderTemplate.new(fetch_partial_path(options[:partial].to_s, view_path), nil, view_path: view_path)
render_partial_with_options template, options
end

def array!(collection = [], *attributes, &block)
Expand Down Expand Up @@ -53,24 +53,24 @@ def partialized(path)
partial_file.join("/")
end

def render_partial_with_options(options)
def render_partial_with_options(template, options)
options[:locals] ||= {}
if options[:as] && options.key?(:collection)
collection = options.delete(:collection)
locals = options.delete(:locals)
array! collection do |member|
member_locals = locals.clone
member_locals.merge! options[:as] => member
render_partial member_locals
render_partial template, member_locals
end
else
render_partial options[:locals]
render_partial template, options[:locals]
end
end

def render_partial(options)
def render_partial(template, options)
options.merge! json: self
@template.render @scope, options
template.render @scope, options
end
end

Expand Down

0 comments on commit 403e2a9

Please sign in to comment.