owl icon indicating copy to clipboard operation
owl copied to clipboard

better error message when owl cannot find a template

Open ged-odoo opened this issue 5 years ago • 1 comments

This component:

class MyComponent extends Component {
    template = xml`<div>hello</div>`;
}

will fail with the message: Could not find template for component "Parent"

But in this case, it can infer that there is actually a (non static) template property. So, it would be more developer-friendly if in this specific case, it would give the following error message: Could not find template for component "Parent". However, there is a (instance, not a class) 'template' property. Maybe this should simply be defined as a class (or static) property?

ged-odoo avatar Apr 07 '20 09:04 ged-odoo

How can i load a template from an XML file.

For example i have this:

Hello\
    hello.html
    hello.js
    hello.xml
    owl.min.js

Here are my codes:

hello.html

<!DOCTYPE html>
<html>
<head>
	<title>Hello</title>
	<script type="text/javascript" src="owl.min.js"></script>
	<script type="module" src="hello.js"></script>
</head>
<body>
</body>
</html>

hello.js

const { Component } = owl;
const { xml } = owl.tags;

class App extends Component {
  static template = TemplateTags;
}

const app = new App();
app.mount(document.body);

hello.xml

<div>Hello Owl</div>

How can i load TemplateTags from my hello.xml file?

I looked into Jabberwock repo but i can't understood, please help!

abdounasser202 avatar May 14 '20 15:05 abdounasser202