-
Notifications
You must be signed in to change notification settings - Fork 346
Style Guidelines
Géry Debongnie edited this page May 17, 2019
·
6 revisions
You will find here a list of coding guidelines, useful to unify the look of your Owl code. This is only a suggestion, but this is what we will try to follow for Odoo code.
class MyComponent extends owl.Component {
constructor(parent, props) {}
...
mounted() {
}
// Rest
doSomething() {
}
}
This is useful because templates can be inferred from the component name,
but only if it is unique. In Odoo, we will prefix component names with
the name of the odoo addon. For example, POSWidget
, or WebActionManager
.
It is ok to read directly from props
in a template. It helps to understand
where a value come from:
<div><t t-if="props.someFlag">Hello</t></div>
It may happen that you need to process some derived value, from the props
and
possibly other part of your component. A nice way to do that is to use a getter:
class MyComponent extends owl.Component {
get derivedInfo() {
// some complicated calculation involving props
return someResult;
}
}
<div><t t-esc="derivedInfo"/></div>