I think the way I’d go about this is using partials, using the Rendering helper
. You’re already using the rendering helper, but I think the missing piece you need is passing in the item to the partial, e.g. using <%= render '/partials/dignities/', item: @item %>
. The extra argument passes the item to the partial, so that the partial itself also has access to @item
. Also refer to the second example in the Rendering helper documentation.
You’ll indeed still need to run the erb filter first — the Markdown filters won’t know how to deal with erb and will all mess it up I believe.
With this approach, you’ll have partials that have access to the original item (and thus its metadata) and you can split up pieces of code, reuse it elsewhere, and not duplicate any code.
One more thing: I spotted <%= @item[:dignities] %> in content/_inc/dignities.md. This is probably not what you intend, because dignitiesis evaluated first, which evaluates to "d", so that piece of code is effectively equal to <%= @item["d"] %>.
Let me know how it goes!