Reusing Rails Views or Partials
Components reusing partials
<%= link_to product_path(product), class: 'product-teaser' do %>
<div>
<h2><%= product.name %></h2>
<p><%= product.description %></p>
<b><%= product.price %></b>
</div>
<% end %>class Components::Products::Trending < Matestack::Ui::Component
def prepare
@products = Product.where(trending: true)
end
def response
h1 'Trending products'
@products.each do |product|
rails_render partial: '/products/teaser', locals: { product: product }
end
end
endComponents reusing views
Last updated
Was this helpful?