Naofumi Kagami's Avatar

Naofumi Kagami

@naofumik

Aspiring "Front-end" Ruby on Rails developer

7
Followers
4
Following
10
Posts
21.12.2024
Joined
Posts Following

Latest posts by Naofumi Kagami @naofumik

Preview
Tag helper buffer for nested elements with multiple children by naofumi · Pull Request #54042 · rails/rails Motivation / Background This Pull Request adds a buffer to the content block in ActionView::Helpers::TagHelper#tag. This allows us to easily generate HTML for nested elements with multiple children...

The pull request is now out.

Thank you all for your comments and encouragement. Let's see how it goes from here.

github.com/rails/rails/...

24.12.2024 06:48 👍 1 🔁 1 💬 0 📌 0
Preview
Tag helper buffer for nested elements with multiple children by naofumi · Pull Request #54042 · rails/rails Motivation / Background This Pull Request adds a buffer to the content block in ActionView::Helpers::TagHelper#tag. This allows us to easily generate HTML for nested elements with multiple children...

The pull request is now out.

Thank you all for your comments and encouragement. Let's see how it goes from here.

github.com/rails/rails/...

24.12.2024 06:48 👍 1 🔁 1 💬 0 📌 0

Thank you, and yes, that safe_join technique is what I have been using too.

With the excitement around Hotwire based UI component libraries and Tailwind, I think it’s time to codify that into Rails itself.

23.12.2024 11:21 👍 2 🔁 0 💬 1 📌 0
Preview
Rails View Helpers for Components This post is intended to gather feedback on a proposal for a new feature for Rails, while I put...

This is a proposal for an extension to Rails tag helpers, that will enable us to write slightly more complex HTML in pure Ruby inside our view helpers.

I think it could help us more conveniently write light-weight components.

I welcome any feedback!

dev.to/naofumik/rai...

@skillstopractice.com

23.12.2024 08:18 👍 3 🔁 0 💬 2 📌 0
Preview
Rails View Helpers for Components This post is intended to gather feedback on a proposal for a new feature for Rails, while I put...

I've just published a blog post with more details on the motivation. I also hope to get a PR out soon. Maybe I can nudge you just a bit closer to view helpers 😀

dev.to/naofumik/rai...

23.12.2024 01:08 👍 0 🔁 0 💬 0 📌 0

Phlex is very good at aligning the two structures. However, by adding a small feature to plain view helpers, I think they can be almost just as good too. I want to discuss this approach.

22.12.2024 02:02 👍 1 🔁 0 💬 1 📌 0

The point of my proposal is to extend the point at which you need to fall back to ERb. In my experience, the major pain point with tag helpers the Ruby code structure often deviates from the HTML structure.

22.12.2024 02:02 👍 0 🔁 0 💬 1 📌 0

Thank you. My position is that if we can shift the middle ground just a little bit, we can have view helpers covering most primary/utility components. For example, we could probably write and compose the components in Shadcn with view helpers.

Can you share more details on the + operator approach?

22.12.2024 01:37 👍 1 🔁 0 💬 0 📌 0

Thank you for the feedback. I fully understand your preference.

Personally, I often do something similar to this using `safe_join`, just to push the limit of helpers so that it encompasses the size of "Components", but I am looking for a better syntax. 😀

22.12.2024 01:31 👍 1 🔁 0 💬 1 📌 0
Post image Post image

Briefly, it will allow you to compose HTML in view helpers like this. Currently, blocks in tag helpers only use the return value so this approach was cumbersome when you had multiple tags. I'm proposing an approach that will make it more like Phlex.

21.12.2024 07:56 👍 2 🔁 0 💬 2 📌 0

@garrettdimon.com Hello! I just sent you an email regarding your article on ERb and Partials. I have a proposal for improving the helper approach, and I would be very happy if you could give me some feedback.

21.12.2024 06:02 👍 1 🔁 0 💬 1 📌 0