Replies: 4 comments 1 reply
-
I like the Serbea has the |
Beta Was this translation helpful? Give feedback.
-
A related discussion along these lines: ViewComponent/view_component#1293 (comment) |
Beta Was this translation helpful? Give feedback.
-
For the moment, I add a plugin with an easy-to-type name which renders the component to turn Would it be possible to allow components to register helper tag (or tags)? Here's the syntax I'd love to use: class Separator::Plain
# By default, the underscored class name is automatically added
view_tag :separator_plain # automatically added
# A custom name can also be added (to call a component with default values, for instance)
view_tag :plain_separator
# The default view_tag could also be prevented
view_tag false
end |
Beta Was this translation helpful? Give feedback.
-
@goulvench I do like this idea quite a bit. There are a few implementation details to consider (for example, |
Beta Was this translation helpful? Give feedback.
-
Bridgetown components are great for building self-contained content blocks (e.g. with Tailwind and AlpineJS). However, templates sometimes looks like this:
Instantiation with
new
could quite easily be eliminated (for those who want) to make the templates a little less verbose such as:Personally, I like the shorter versions, however, I'm not sure whether this kind of syntactical sugar would be appreciated by others as well. And I'm not really a fan of monkey patching such things for individual projects.
render Separator::Plain[color: 'zinc-300']
(a shorthand syntax borrowed from stdlibPathname
) it only takes a simplealias_method :[], :new
in the Components class.render Prose
, the render method has to instantiate the passed object if it is a Class instance.What do you think, too much bling-bling or worth the extra code?
/cc @jaredcwhite
Beta Was this translation helpful? Give feedback.
All reactions