2024-06-09 15:40:58 -07:00
|
|
|
-# Run the block first, so we can get the subtitle content if provided! Clear
|
|
|
|
-# out any old values beforehand, too.
|
|
|
|
- content_for :subtitle, "", flush: true
|
Move Item Getting Guide subtitle UI out of helpers, into templates
I thought to myself, "I wonder if it's possible to use a sneaky hacky
`content_for` trick to be able to run this code in the template." And
indeed it is!
It's tricky cuz like, I want to render this template, and I want to
provide _multiple_ slots of content to it. So, in this variant, we keep
the block as being primarily for the actions, but also optionally
accept `content_for :subtitle` inside that block, too.
Executing that correctly is a bit tricky! The subtitle comes *before*
the actions. So, we `yield` the actions block immediately, save it to a
variable, and *then* get the subtitle block.
2024-06-09 15:03:35 -07:00
|
|
|
- content = yield
|
|
|
|
- subtitle = yield :subtitle
|
2024-05-28 17:05:28 -07:00
|
|
|
|
2024-05-21 18:48:29 -07:00
|
|
|
%tr
|
2024-05-22 14:57:28 -07:00
|
|
|
%td.thumbnail-cell
|
|
|
|
= link_to item_thumbnail_for(item), item, target: "_blank",
|
|
|
|
tabindex: "-1"
|
2024-05-27 15:50:41 -07:00
|
|
|
%td.name-cell
|
|
|
|
= link_to item.name, item, target: "_blank"
|
|
|
|
- if subtitle.present?
|
|
|
|
.subtitle= subtitle
|
Move Item Getting Guide subtitle UI out of helpers, into templates
I thought to myself, "I wonder if it's possible to use a sneaky hacky
`content_for` trick to be able to run this code in the template." And
indeed it is!
It's tricky cuz like, I want to render this template, and I want to
provide _multiple_ slots of content to it. So, in this variant, we keep
the block as being primarily for the actions, but also optionally
accept `content_for :subtitle` inside that block, too.
Executing that correctly is a bit tricky! The subtitle comes *before*
the actions. So, we `yield` the actions block immediately, save it to a
variable, and *then* get the subtitle block.
2024-06-09 15:03:35 -07:00
|
|
|
%td.actions-cell= content
|