vendor/gems/express_templates/lib/arbre/patches.rb in express_admin-1.4.5 vs vendor/gems/express_templates/lib/arbre/patches.rb in express_admin-1.4.6
- old
+ new
@@ -23,10 +23,20 @@
tag
end
end
+ def possible_route_proxy(name)
+ if helpers.controller.class.parent &&
+ helpers.respond_to?(namespace = helpers.controller.class.parent.to_s.underscore)
+ if (route_proxy = helpers.send(namespace)).respond_to?(name)
+ return route_proxy
+ end
+ end
+ return nil
+ end
+
# Implements the method lookup chain. When you call a method that
# doesn't exist, we:
#
# 1. Try to call the method on the current DOM context
# 2. Return an assigned variable of the same name
@@ -38,10 +48,12 @@
current_arbre_element.send name, *args, &block
elsif assigns && assigns.has_key?(name)
assigns[name]
elsif helpers.respond_to?(name)
helper_method(name, *args, &block)
+ elsif route_proxy = possible_route_proxy(name)
+ route_proxy.send(name, *args, &block)
else
super
end
end
@@ -49,9 +61,11 @@
# everywhere we want to try to distinguish helpers that are almost
# always used as parameters to other methods such as path helpers
# and not add them as elements
def helper_method(name, *args, &block)
if name.match /_path$/
+ helpers.send(name, *args, &block)
+ elsif (const_get([name, 'engine'].join('/').classify) rescue nil)
helpers.send(name, *args, &block)
else
current_arbre_element.add_child helpers.send(name, *args, &block)
end
end
\ No newline at end of file