Skip to content

Commit 4e606f5

Browse files
Tomas StrachotaiNecas
Tomas Strachota
authored andcommitted
Fallback to apipie views when application override isn't present
Before this change apipie-rails required all views to be copied into the application's view folder even when only one of the files contained some modification. After this change it is possible to override just a single view.
1 parent b2d3459 commit 4e606f5

File tree

1 file changed

+8
-11
lines changed

1 file changed

+8
-11
lines changed

lib/tasks/apipie.rake

+8-11
Original file line numberDiff line numberDiff line change
@@ -100,17 +100,14 @@ namespace :apipie do
100100
# Attempt to use the Rails application views, otherwise default to built in views
101101
def renderer
102102
return @apipie_renderer if @apipie_renderer
103-
base_path = if File.directory?("#{Rails.root}/app/views/apipie/apipies")
104-
"#{Rails.root}/app/views/apipie/apipies"
105-
else
106-
File.expand_path("../../../app/views/apipie/apipies", __FILE__)
107-
end
108-
layouts_path = if File.directory?("#{Rails.root}/app/views/layouts/apipie")
109-
"#{Rails.root}/app/views/layouts"
110-
else
111-
File.expand_path("../../../app/views/layouts", __FILE__)
112-
end
113-
@apipie_renderer = ActionView::Base.new([base_path, layouts_path])
103+
104+
base_paths = [File.expand_path("../../../app/views/apipie/apipies", __FILE__)]
105+
base_paths.unshift("#{Rails.root}/app/views/apipie/apipies") if File.directory?("#{Rails.root}/app/views/apipie/apipies")
106+
107+
layouts_paths = [File.expand_path("../../../app/views/layouts", __FILE__)]
108+
layouts_paths.unshift("#{Rails.root}/app/views/layouts") if File.directory?("#{Rails.root}/app/views/layouts/apipie")
109+
110+
@apipie_renderer = ActionView::Base.new(base_paths + layouts_paths)
114111
@apipie_renderer.singleton_class.send(:include, ApipieHelper)
115112
return @apipie_renderer
116113
end

0 commit comments

Comments
 (0)