Skip to content

Remove setting of tailwindcss as the default template_engine #131

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 2 commits into from

Conversation

davidteren
Copy link

Not sure why we set g.template_engine :tailwindcss it is not a typical template engine like erb, haml, slim and others.

One adverse effect of setting it to tailwindcss is RSpec view generators will not use the correct template name.
Eg: spec/views/home/index.html.tailwindcss_spec.rb where it should be spec/views/home/index.html.erb.rb

Removing the config resolves the above issue.

@dixpac
Copy link
Contributor

dixpac commented Jan 9, 2022

This will break the scaffolding afaik, if we remove the template_engine we'll not get tailwind custom scaffold templates. This is done in order to override the default rails scaffolds https://github.com/rails/tailwindcss-rails/tree/main/lib/generators/tailwindcss.

I'm 100% up for removing the template_engine configuration if you can find the way to override rails scaffolds so we have _partial.html.erb for rails 6 versions 😄 .

Do tailwind scaffolds work for you if you remove this configuration?

@davidteren
Copy link
Author

Thanks for the insights. I'll check properly if the scaffolds work with the configuration removed.

@davidteren
Copy link
Author

@dixpac turns out none of the scaffolds will include the tailwind custom styling with my change. This may be a good thing as this no longer forces it on all users.
If a user wants the custom styling that comes with the gem they can simply prepend the styling directive to the generator.
See the updated Readme.

@dixpac
Copy link
Contributor

dixpac commented Jan 10, 2022

Thanks @davidteren

I don't think this is the direction we wan't to go with, since our main idea with the tailwind generators was to override default rails generators so we don't have to provide tailwindcss:scaffold.

@dhh has the last word on this, but the initial idea was just to use bin/rails g scaffold ... and have the Tailwind styles if this engine is included.

@dixpac
Copy link
Contributor

dixpac commented Jan 10, 2022

Reference

@davidteren
Copy link
Author

@dixpac I think we can close this PR as in its current form it does not align with @dhh's vision of having scaffold templates that demonstrate the use of Tailwind classes.

@dixpac
Copy link
Contributor

dixpac commented Jan 10, 2022

Yup!
But, if you have an inspiration or ideas in the future on how to keep default templates and fix these edge cases.. 🙏🏼

@davidteren davidteren closed this Jan 10, 2022
@marckohlbrugge
Copy link

FWIW, this breaks the haml-rails default configuration and presumably similar integrations.

I didn't expect including the tailwindcss-rails gem would switch my generated views back from .html.haml to .html.erb

@dhh
Copy link
Member

dhh commented Feb 5, 2023

Feel free to explore ways where all this can coexist. But yes, with the tailwind gem installed, scaffolds should be generated with TW styling. Maybe we can detect if another, non-default template handler has already been registered, and then warn/abort, though.

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.

4 participants