XF 2.1 Template conditionals not working as expected in macro

DeltaHF

Well-known member
I want to show unique content in the header of different "new post" widgets. I want to use a macro to do this, but it's not working as expected.

I am calling the macro like so from the widget_new_posts template:
Rich (BB code):
<h3 class="block-minorHeader">
    <a href="{$link}" rel="nofollow">{$title}</a>
    <xf:macro template="myMacroTemplate" name="myMacro" arg-key="{$widget.key}" />
</h3>

The myMacroTemplate template:
Rich (BB code):
<xf:macro name="myMacro"
    arg-key="">
    
    <!-- Sanity Check: {$key} -->

    <xen:if is="$key == 'firstWidget'">
        <div>FOO</div>
    </xen:if>
    
    <xen:if is="$key == 'secondWidget'">
        <div>BAR</div>
    </xen:if>

</xf:macro>

Unfortunately, "FOO" and "BAR" are printed in both widgets. However, the "sanity check" confirms the key is passed correctly, and the 'if' conditional syntax works as expected if I place it directly in the widget_new_posts template.

Why is this happening?
 
Top Bottom