Skip to content
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

Fix: Insert centring container around the yield #106

Merged
merged 1 commit into from
Jan 6, 2022

Conversation

dixpac
Copy link
Contributor

@dixpac dixpac commented Dec 21, 2021

Insertion point of the centering container was problematic.
Meaning, if someone has a yield :somethig
inside theirs application.html.erb old regex would pick that as a
insertion point and possiblly break the html structure.

This commit makes that regex more rigid to only insert centering
container around the <%= yield %>.

Fixes: #98

Insertion point of the centering container was problematic.
Meaning, if someone has a `yield :somethig`
inside theirs `application.html.erb` old regex would pick that as a
insertion point and possiblly break the html structure.

This commit makes that regex more rigid to only insert centering
container around the `<%= yield %>`.
insert_into_file APPLICATION_LAYOUT_PATH.to_s, %( <main class="container mx-auto mt-28 px-5 flex">\n ), before: /^\s*<%= yield/
insert_into_file APPLICATION_LAYOUT_PATH.to_s, %(\n </main>), after: /^\s*<%= yield %>/

insert_into_file APPLICATION_LAYOUT_PATH.to_s, %( <main class="container mx-auto mt-28 px-5 flex">\n ), before: CENTERING_CONTAINER_INSERTION_POINT
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One more thing we could do here is to ask a question does user want to insert centering contianer

if yes?("Do you want to insert self-centering html attribute inside your aplication.html.erb")
  insert_into_file APPLICATION_LAYOUT_PATH.to_s, %(    <main class="container mx-auto mt-28 px-5 flex">\n  ), before: /^\s*<%= yield %>/
  insert_into_file APPLICATION_LAYOUT_PATH.to_s, %(\n    </main>),  after: /^\s*<%= yield %>/
end

This would only be useful for folks installing tailwindcss-rails on already established app UI aesthetics

@dixpac
Copy link
Contributor Author

dixpac commented Jan 6, 2022

cc @dhh (not sure if you forgot about this patch, or you don't like the solution 😃 )

@dhh dhh merged commit dcd0973 into rails:main Jan 6, 2022
@dhh
Copy link
Member

dhh commented Jan 6, 2022

All good 👍

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.

Generator of main closing tag is broken if yield has arguments
2 participants