Skip to content

Prioritize custom view templates #247

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from

Conversation

mojodojo101
Copy link

Current behavior:
Custom templates are ignored by the tailwindcss-rails generator

Expected behavior:
View templates under "#{RAILS_ROOT}/lib/templates/erb/scaffold" should be prioritized by the generator.

#164

@flavorjones
Copy link
Member

@mojodojo101 Thanks for submitting this. CI is failing, can you look into it, please?

@mojodojo101
Copy link
Author

@mojodojo101 Thanks for submitting this. CI is failing, can you look into it, please?

Hmm, i guess Rails.root isnt initialized in those tests, would it be fine to simply check if its nil with an if statement or is that piece of code i wrote just rubbish?

@flavorjones
Copy link
Member

Can you please remove the version bump and changelog entry from this PR to avoid conflicts?

Would it be possible to write a test to describe the behavior you're introducing?

@mojodojo101
Copy link
Author

I removed the Changelog and Version bump 😄 . I dont know much about writing tests/ integration tests so i might have to look into that once i have some time on my hands.

The tldr of the behavior introduced here is:

  • Check if there is a /lib/templates/erb/scaffold folder in rails
  • If that is the case use the templates in that scaffold folder rather than the folder provided by tailwindcss-rails

Following the procedure that is described here

https://guides.rubyonrails.org/generators.html :
... Another common use of custom templates is overriding the default scaffold view templates. You can override any of these by creating the appropriate file (e.g. index.html.erb, show.html.erb, etc) in lib/templates/erb/scaffold.


At the moment it just checks if the folder is there, if we want file granularity, this commit wont do just fyi.

@rgarver
Copy link

rgarver commented Aug 12, 2023

I just hit this issue. Is there any additional work required to make this mergeable?

@flavorjones
Copy link
Member

I'm closing this in preference of #314 which is a simpler fix and has test coverage.

@flavorjones flavorjones closed this Jan 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants