XF 2.2 Why can't macro extension names be variables?

Jaxel

Well-known member
I am overwriting a thread_type template with:
Code:
<xf:extends template="{$templateOverrides.ewr_porta_thread_type}" />

I am trying to overwrite a macro the same way with:
Code:
<xf:macro name="answer" extends="{$templateOverrides.ewr_porta_post_macro}">

But that returns an error:
Extension names must be literal strings.
 
Variables are only known at runtime but extensions are compiled into the executable version of the template so we must know the value of what we're extending at the time we compile the template.
 
Let me explain further. Right now I have a template that looks like this:

HTML:
<xf:macro name="post" extends="post_macros::post">
    <xf:extension name="extra_classes">message--simple <xf:extensionparent /></xf:extension>
    <xf:extension name="user_cell"><xf:macro name="post_user_info" arg-post="{$post}" /></xf:extension>
    <xf:extension name="attribution"><xf:macro name="post_attribution" arg-post="{$post}" arg-thread="{$thread}" /></xf:extension>
    <xf:extension name="signature" />
</xf:macro>

<xf:macro name="answer" extends="post_question_macros::answer">
    <xf:extension name="extra_classes">message--simple <xf:extensionparent /></xf:extension>
    <xf:extension name="user_cell"><xf:macro name="post_user_info" arg-post="{$post}" /></xf:extension>
    <xf:extension name="attribution"><xf:macro name="post_attribution" arg-post="{$post}" arg-thread="{$thread}" /></xf:extension>
    <xf:extension name="signature" />
</xf:macro>

<xf:macro name="suggestion" extends="post_suggestion_macros::suggestion">
    <xf:extension name="extra_classes">message--simple <xf:extensionparent /></xf:extension>
    <xf:extension name="user_cell"><xf:macro name="post_user_info" arg-post="{$post}" /></xf:extension>
    <xf:extension name="attribution"><xf:macro name="post_attribution" arg-post="{$post}" arg-thread="{$thread}" /></xf:extension>
    <xf:extension name="signature" />
</xf:macro>

Three identical macros. The only difference between them is the extension parent. I'm looking for a way to reduce this redundancy.
 
Last edited:
Top Bottom