Skip to content

Commit 27fca1f

Browse files
committed
Add support for packs and internal engines
When using packs or internal engines, the template paths may not be nested directly under the Rails root `app/views` directory. For example, the default for packs-rails is to use a `packs` directory under the Rails root, so the layout could be in a directory like `#{Rails.root}/packs/pack_name/app/views`. Since the view paths are registere with `ActionController::Base.view_paths`, we can use that collection to clearly identify local templates
1 parent 89296bf commit 27fca1f

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

  • lib/reactionview/template/handlers

lib/reactionview/template/handlers/herb.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,9 @@ def layout_template?(template)
4040
def local_template?(template)
4141
return true unless template.respond_to?(:identifier) && template.identifier
4242

43-
template.identifier.start_with?("#{Rails.root}/app/views")
43+
ActionController::Base.view_paths
44+
.select { |view_path| view_path.path.start_with?(Rails.root.to_s) }
45+
.any? { |view_path| template.identifier.start_with?(view_path.path) }
4446
end
4547

4648
def active_support_editor

0 commit comments

Comments
 (0)