Open collimarco opened 1 year ago
Yeah, good point, we don't have anything quite like this out of the box — iirc we'll try to to_s
these values immediately.
I've been trying to think of a way to collect these Array like values and defer the to_s
, but it's not the easiest and could have other implications.
We do have the ability to yield
into a block. I haven't tried this, but I'm wondering if this would be a fit?
<%= render "components/nav" do |partial| %>
<% partial.link { _1.link_to "Link 1", page_path } %>
<% partial.link { _1.link_to "Link 2", another_path } %>
<% end %>
<%# app/views/components/_nav.html.erb %>
<%# Here we're yielding an element that the rendering block above can finalize by passing a block. %>
<% partial.link.yield with_options(class: "text-m4", data: { controller: "title" }) %>
<a href="…" class="text-m4" data-controller="title">Link 1</a>
<a href="…" class="text-m4" data-controller="title">Link 2</a>
cc @seanpdoyle I'm wondering if you've run into something like this and how you've handled it in your use of Nice Partials.
I ran into this, we should probably add it to the README. I'll set something up.
@julianrubisch sounds good!
Any updates on this?
It would be nice to have a feature like this:
https://viewcomponent.org/guide/slots.html
For example, if you want to create a nav component, you may want to add multiple links: