lib/jets/controller/rendering/rack_renderer.rb in jets-1.7.2 vs lib/jets/controller/rendering/rack_renderer.rb in jets-1.8.0

- old
+ new

@@ -28,10 +28,11 @@ # Rails rendering does heavy lifting if drop_content_info?(status) body = StringIO.new else + renderer = ActionController::Base.renderer.new(renderer_options) body = renderer.render(render_options) body = StringIO.new(body) end @@ -189,11 +190,11 @@ def setup! require "action_controller" require "jets/overrides/rails" # Load helpers - # Assign local variable because scoe in the `:action_view do` changes + # Assign local variable because scope in the `:action_view do` block changes app_helper_classes = find_app_helper_classes ActiveSupport.on_load :action_view do include ApplicationHelper # include first app_helper_classes.each do |helper_class| include helper_class @@ -205,14 +206,21 @@ setup_webpacker if Jets.webpacker? end # Does not include ApplicationHelper, will include ApplicationHelper explicitly first. def find_app_helper_classes + internal_path = File.expand_path("../../internal", File.dirname(__FILE__)) + internal_classes = find_app_helper_classes_from(internal_path) + app_classes = find_app_helper_classes_from(Jets.root) + (internal_classes + app_classes).uniq + end + + def find_app_helper_classes_from(project_root) klasses = [] - expression = "#{Jets.root}/app/helpers/**/*" + expression = "#{project_root}/app/helpers/**/*" Dir.glob(expression).each do |path| next unless File.file?(path) - class_name = path.sub("#{Jets.root}/app/helpers/","").sub(/\.rb/,'') + class_name = path.sub("#{project_root}/app/helpers/","").sub(/\.rb/,'') unless class_name == "application_helper" klasses << class_name.classify.constantize # autoload end end klasses