Dynamic attributes using dicts and lists

We have gone through the most important QWeb directives, but there are a few more we should be aware of. Let's look at a short explanation of them.

We have seen the t-att-NAME and t-attf-NAME style dynamic tag attributes. Additionally, the fixed t-att directive can be used. It accepts either a key-value dictionary mapping or a pair (a two-element list).

Use the following mapping:

<p t-att="{'class': 'oe_bold', 'name': 'test1'}" /> 

This results in the following:

<p class="oe_bold" name="test1" /> 

Use the following pair:

<p t-att="['class', 'oe_bold']" /> 

This results in the following:

<p class="oe_bold" /> 

Get Odoo 11 Development Essentials - Third Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.