discover-unused-partials icon indicating copy to clipboard operation
discover-unused-partials copied to clipboard

ERB template partials are unresolved

Open juanca opened this issue 3 years ago • 2 comments

Description

I am getting an error when using a partial in one of my layout ERB files. I have tried a variety of permutations and nothing works. The following example is the "most direct" use of a partial.

Output

% bundle exec discover-unused-partials
The following partials are not referenced directly by any code:
  app/views/top-bar/_support_dropdown.html.erb


Some of the partials above (at any level) might be referenced dynamically by the following lines of code:
  app/views/layouts/_header.html.erb:<%= render partial: 'top-bar/support_dropdown', locals: {

Expected

I would have expected the gem to consider the default filename + path resolution.

Suggested solution

Rails has a set of default directories to search for views. It should be possible to also hook into it and resolve the requested "dynamic" render into a real path.

Or, am I doing something wrong?

juanca avatar Feb 25 '21 21:02 juanca

I was on 3.3. Just updated to 3.5 (latest). Same issue.

juanca avatar Feb 25 '21 21:02 juanca

Okay, I found the real bug.

The issue is the folder name. A hyphen in the path will break the gem.

F

juanca avatar Feb 25 '21 22:02 juanca