I have a need for something like the following:
{# Template A #}
{# Do X that sets variable x #}
{# Do Y that sets variable y #}
{# Pass x and y into A include partials #}
{# Template B #}
{# Do X that sets variable x #}
{# Do Y that sets variable y #}
{# Pass x and y into B include partials #}
The logic for X and Y is the same in templates A and B.
Is there a way to write each once in some kind of dedicated partial and place them in templates A and B, something akin to return
in a JavaScript function?
I'm not sure there is. I think that macros only produce front-end output. And so I have to duplicate the logic in each template. Is that right?
return
scope, which I think is what I need, but I’m nervous about relying on a third party plugin for this. Would be great if it were native to Craft.