forked from OpenNeo/impress
Emi Matchu
1f0c8b87a6
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.
13 lines
361 B
Text
13 lines
361 B
Text
-# Run the block first, so we can get the subtitle content if provided!
|
|
- content = yield
|
|
- subtitle = yield :subtitle
|
|
|
|
%tr
|
|
%td.thumbnail-cell
|
|
= link_to item_thumbnail_for(item), item, target: "_blank",
|
|
tabindex: "-1"
|
|
%td.name-cell
|
|
= link_to item.name, item, target: "_blank"
|
|
- if subtitle.present?
|
|
.subtitle= subtitle
|
|
%td.actions-cell= content
|