odoo / owl

OWL: A web framework for structured, dynamic and maintainable applications
https://odoo.github.io/owl/
Other
1.17k stars 350 forks source link

`t-if=""` generates invalid javascript when compiling the template #1634

Open LucasLefevre opened 3 months ago

LucasLefevre commented 3 months ago

t-if="" generates code which is not valid javascript.

it generates code which looks like

"""
if () {
   // ...
}
"""

It crashes when owl tries to compile the code Error: Failed to compile template "Root": Unexpected token ')'

The error message isn't very helpful to debug/fix the xml template, especially if the template is quite large and the generated code is also big.

class Root extends Component {
    static components = {};
    static template = "Root"
}
<templates>
  <t t-name="Root">
    <div t-if="">Hi!</div>
  </t>
</templates>

:point_right: Playground

ged-odoo commented 3 months ago

yeah, seems like we could improve this...