MishkaCmsCore. Runtime. Resources. Calculations. RenderContent
(Mishka CMS Core v0.0.1)
Copy Markdown
View Source
A reusable calculation that exposes a plugin-transformable rendered version of a content field —
the Ash-idiomatic equivalent of the WordPress the_content / Joomla onContentPrepare filter.
Add it as a calculation over the source attribute you display:
calculations do
calculate :rendered_content, :string,
{MishkaCmsCore.Runtime.Resources.Calculations.RenderContent, source: :content}
endThen load :rendered_content wherever you display the content (admin grid column, JSON API field,
a future public article view) instead of the raw attribute. For each record it calls
"<app>:<resource>:render_<source>" with %{html: raw, record: record}; a plugin returns
%{html: transformed} (shortcodes, oEmbed, related-posts, ToC, syntax-highlight, SEO injection…).
With no plugin registered the raw value is returned unchanged.
It runs at display/load time, so plugins must be pure and cheap (operate on already-fetched data; never fetch a remote oEmbed here — precompute + cache, only string-substitute at render).
Summary
Functions
Callback implementation for Ash.Resource.Calculation.describe/1.
Callback implementation for Ash.Resource.Calculation.has_expression?/0.
Callback implementation for Ash.Resource.Calculation.strict_loads?/0.
Functions
Callback implementation for Ash.Resource.Calculation.describe/1.
Callback implementation for Ash.Resource.Calculation.has_expression?/0.
Callback implementation for Ash.Resource.Calculation.strict_loads?/0.