Adding QWeb dynamic content
The QWeb parser looks for special attributes (directives) in the templates and replaces them with dynamically generated HTML.
For kanban views, the parsing is done by client-side JavaScript. This means that the expression evaluations done by QWeb should be written using the JavaScript syntax, not Python.
When displaying a kanban view, the internal steps are roughly as follows:
Get the XML for the templates to render.
Call the server
read()
method to get the data for the fields in the templates.Locate the
kanban-box
template and parse it using QWeb to output the final HTML fragments.Inject the HTML in the browser's display (the DOM).
This is not meant to be technically exact. It is just a mind map that can be useful to understand how things work in kanban views.
Next we will explore the several QWeb directives available, using examples that enhance our to-do task kanban card.
Conditional rendering with t-if
The t-if
directive, accepts a JavaScript expression to be evaluated...