Skip to content

Commit

Permalink
Merge pull request #164 from CDRH/fix-overrides
Browse files Browse the repository at this point in the history
Fix render_overridable
  • Loading branch information
jduss4 authored Oct 25, 2019
2 parents 9d9a873 + 7e5029f commit aad542d
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
9 changes: 7 additions & 2 deletions app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,14 @@ def render_overridable(path="", view="", **kwargs)
# False when looking for views rather than partials
is_partial = false

if @section.present? && lookup_context.template_exists?(view,
"#{@section}/#{path}", is_partial)
if @section.present? && path.is_a?(String) &&
lookup_context.template_exists?(view, "#{@section}/#{path}",
is_partial)
path = "#{@section}/#{path}"
elsif @section.present? && path.is_a?(Array) &&
lookup_context.template_exists?(view, "#{@section}/#{path[0]}",
is_partial)
path = "#{@section}/#{path[0]}"
elsif !lookup_context.template_exists?(view, path, is_partial)
# Log error and display 404 view if view is missing
path << "/" if path.present?
Expand Down
10 changes: 8 additions & 2 deletions app/helpers/orchid/application_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -210,9 +210,15 @@ def render_overridable(path="", partial="", **kwargs)

# True when looking for partials rather than views
is_partial = true
if @section.present? && lookup_context.template_exists?(partial,
"#{@section}/#{path}", is_partial)

if @section.present? && path.is_a?(String) &&
lookup_context.template_exists?(partial, "#{@section}/#{path}",
is_partial)
path = "#{@section}/#{path}"
elsif @section.present? && path.is_a?(Array) &&
lookup_context.template_exists?(partial, "#{@section}/#{path[0]}",
is_partial)
path = "#{@section}/#{path[0]}"
elsif !lookup_context.template_exists?(partial, path, is_partial)
# fallback to informative partial about customization
path << "/" if path.present?
Expand Down

0 comments on commit aad542d

Please sign in to comment.