Skip to content

Rendering Slim to a variable

Uwe Kubosch edited this page Mar 13, 2020 · 1 revision

A construct I have used increasingly is the ability to render a template fragment to a variable without having to use a separate partial file.

Using the capture method, we can get back the rendered content for manipulation as we choose.

- tags = [:one, :two, :three].map do |number|
  - capture
    span.text-nowrap #{number}
== tags.join(", ")
Clone this wiki locally