RablRails now accepts local methods for child nodes and

root objects. Local methods are used by decent_exposure or
focused_controller
This commit is contained in:
ccocchi 2012-09-12 01:34:54 +02:00
parent dc66b43638
commit 8376c0d974
2 changed files with 11 additions and 3 deletions

View File

@ -133,7 +133,7 @@ module RablRails
name_or_data
end
end
def sub_compile(data)
return {} unless block_given?
old_template, @template = @template, {}

View File

@ -18,7 +18,9 @@ module RablRails
# method defined by the renderer.
#
def render(template)
collection_or_resource = instance_variable_get(template.data) if template.data
collection_or_resource = if template.data
template.data.to_s.start_with?('@') ? instance_variable_get(template.data) : @_context.send(template.data)
end
collection_or_resource = @_context.target_object unless collection_or_resource || template.data == false || !@_context.respond_to?(:target_object)
output_hash = collection_or_resource.respond_to?(:each) ? render_collection(collection_or_resource, template.source) :
render_resource(collection_or_resource, template.source)
@ -55,7 +57,13 @@ module RablRails
when Hash
current_value = value.dup
data_symbol = current_value.delete(:_data)
object = data_symbol.nil? ? data : data_symbol.to_s.start_with?('@') ? instance_variable_get(data_symbol) : data.send(data_symbol)
object = if data_symbol == nil
data
else
data_symbol.to_s.start_with?('@') ? instance_variable_get(data_symbol)
: data.respond_to?(data_symbol) ? data.send(data_symbol)
: send(data_symbol)
end
if key.to_s.start_with?('_') # glue
current_value.each_pair { |k, v|