Passa al contenuto
Menu
È necessario essere registrati per interagire con la community.
La domanda è stata contrassegnata
2 Risposte
10675 Visualizzazioni

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
Abbandona
Autore Risposta migliore

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
Abbandona
Risposta migliore

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
Abbandona

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