This question has been flagged
1 Reply
15619 Views

Hello all,

Let's take an example. I have an image in a website template like this :

<template id="website.company_description" name="Company Description">            
            <a t-att-href="res_company.google_map_link()" target="_BLANK">
                <img alt="Retrouvez Intime &amp; vilain sur la carte" class="thumbnail img-responsive" t-att-src="res_company.google_map_img()" />
            </a>
</template>


I use alt in the image tag and it seems to render correctly.

Should I use t-att-alt instead?

I don't understand the difference between alt and t-att-alt in a qweb template... Could you explain to me please?


Avatar
Discard
Best Answer

Hi Pascal 

The difference is that in t-att-alt is to be able to use qweb dynamic attributes to render the value using expressions, you could read more about qweb attributes here:

https://www.odoo.com/documentation/8.0/reference/qweb.html#attributes

for example you could insert an expression inside your t-att-alt attribute to get the final alt attribute value based on any qweb context value like you are doing with t-att-href or any other t-att- attribute, like:

<template id="website.company_description" name="Company Description">            
    <a t-att-href="res_company.google_map_link()" target="_BLANK">
        <img t-att-alt="'Retrouvez Intime &amp; vilain sur la carte: ' +str(res_company.google_map_link())" class="thumbnail img-responsive" t-att-src="res_company.google_map_img()" />
    </a>
</template>
Avatar
Discard
Author

If I understand, I would say that if I have no dynamic attribute to insert, I could use only 'alt' instead of 't-att-alt'. Do you agree?

Yes, you just use t-tt- atributes for dynamic attribute values that you need to build and/or output

Author

Thanks my friend. I finally managed to see your face on your Twitter account ... Nice little guy!!! I would like to be so pretty! Ah ah!