Replies: 4 comments 2 replies
-
FWIW, I totally agree here 😟 API consistency, and familiarity with the shape of HTML has been really valuable based on my experience of Phlex. There are also caveats to supporting inline tags, such as not allowing nesting... h1(h2("Hi")) or mixing the positional arg and a block... h1("Hello") { "World" } And of course this will also prevent the use of positional args for any current or future use. While you may not be able to think of a use for them right now, but by supporting inline tags, and reserving the (first) positional arg, you are shutting that down completely. I actually use positional arguments in some tags and custom tags, so I would expect this to break some of my code I see no benefit to this, other than perhaps it looks a little nicer all on one line, which with all else being equal, I would be a fan of. But unfortunately that is not the case here. |
Beta Was this translation helpful? Give feedback.
-
Thanks for your feedback on this @davekaro. @willcosgrove and I went back and forth on this a bunch before merging the PR and maybe we made the wrong decision. Some things we considered were Arguments for
Arguments against
I’m not against reverting this change. |
Beta Was this translation helpful? Give feedback.
-
Some other thoughts:
|
Beta Was this translation helpful? Give feedback.
-
Thanks for your feedback @davekaro, @joelmoss, @hangsu, @Vagab. We decided to revert this change. |
Beta Was this translation helpful? Give feedback.
-
In #755, support for inline tags was added. You can now render content like
h1("Hello")
as well ash1 { "Hello" }
.When I first saw this PR, I was not sure how I felt about it because after writing about 600 views/components in my app, I've never really wished I had this ability. Reading https://judoscale.com/blog/phlex-not-erb helped explain the major downside of supporting this way of setting the content, namely the structure of the HTML becomes more obfuscated. See this quote from the section titled "Seeing the shape of the markup":
By supporting content as the first positional parameter, can we still say "Phlex encourages you to shape your Ruby just as you would your HTML"?
Another downside I realized when working on some code this morning, a simple component like this:
h1(class: "text-green-500") { "Hello" }
might also be written as:
h1("Hello", class: "text-green-500")
and now I have to decide every time whether I want to use the block form or the positional param form.
Would love to hear others thoughts on this. In the linked issue, the only upside of supporting this method of setting content was to make migration from another (legacy) gem simpler. Is this enough reason to add this feature? Are there benefits I'm missing?
Beta Was this translation helpful? Give feedback.
All reactions