Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

t-else with t-widget #37

Closed
alexkuhn opened this issue Apr 16, 2019 · 2 comments
Closed

t-else with t-widget #37

alexkuhn opened this issue Apr 16, 2019 · 2 comments
Labels
bug Something isn't working

Comments

@alexkuhn
Copy link
Contributor

const {Component, QWeb} = owl.core;

class Child extends Component {
    constructor() {
        super(...arguments);
        this.template = "child"
    }
}

class App extends Component {
  constructor() {
    super(...arguments);
    this.template = "app";
    this.widgets = { Child };
  }
}

const qweb = new QWeb(TEMPLATES);
const app = new App({qweb});
app.mount(document.body);
<templates>
  <div t-name="app">
    <div t-if="0"/>
    <t t-else="" t-widget="Child" t-props="{ test: 0 }"/>
  </div>
  
  <div t-name="child">
      <t t-esc="props.test"/>
  </div>
</templates>

Crashes with the following error:

Invalid generated code while compiling template 'app': Unexpected token )
@alexkuhn
Copy link
Contributor Author

If we split t-else and t-widget, works fine:

<t t-else="">
   <t t-widget="Child" t-props="{ test: 0 }"/>
</t>

@alexkuhn alexkuhn added the bug Something isn't working label Apr 16, 2019
@ged-odoo
Copy link
Contributor

it is because you use the t-else with a falsy value. If you write <t t-else="1" t-widget="Child" t-props="{ test: 0 }"/>, it will work

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants