This question has been flagged
2 Replies
9799 Views

I am trying to output ltr/rtl variable lang_direction in qweb tamplate like this:

            <xpath expr="//html" position="attributes">
                <attribute name="dir"><t t-esc="lang_direction"/></attribute>
            </xpath>            

This is not working. Is there a way to do it?

 

Avatar
Discard
Author Best Answer

I used t-att-$name instead of t-attf

So it should be


<xpath expr="//html" position="attributes">

        <attribute t-if="lang_direction == 'ltr'" name="t-attf-dir">ltr</attribute>

        <attribute t-if="lang_direction == 'rtl'" name="t-attf-dir">rtl</attribute>

</xpath>

Avatar
Discard
Best Answer

Hello Akram,

What about a workaround like the following:

<xpath expr="//html" position="attributes">
        <attribute t-if="lang_direction == 'ltr'" name="dir">ltr</attribute>
        <attribute t-if="lang_direction == 'rtl'" name="dir">rtl</attribute>
</xpath>   

Avatar
Discard

Can we only set an attribute with xpath? Can we set it directly?