Géry Debongnie 3bf91afc3f [FIX] qweb: fix issue variables set in body of t-call
The body of a t-call directive may be used to define private variables
to the sub template call.

However, the code that handles t-call worked like this:

- compile sub template if necessary
- then compile body of t-call to extract variables

This means that the variables defined in the t-call body were not yet
processed and available in the context.  Because of that, when the call
to t-esc is done, there is not internal qweb var, and the code simply
outputs a scope['varname'], which is in our case a VDOMArray, so it is
displayed as [object object]

What this fix does is changing the way t-esc works: if we are in the
context of a sub template, then it assumes that any outside variable may
or may not be a VDomArray, so it needs to check and eventually convert
it to a string, if necessary.

closes #719
2020-09-16 11:39:32 +02:00
2020-02-17 13:06:23 +01:00
2019-03-18 14:26:33 +01:00
2019-10-01 20:44:39 +02:00
2019-05-03 16:19:33 +02:00
2020-06-02 10:38:32 +02:00
2020-06-02 10:38:32 +02:00
2020-06-02 10:38:32 +02:00
2020-01-09 14:35:13 +01:00

🦉 OWL Framework 🦉

Class based components with hooks, reactive state and concurrent mode

Project Overview

The Odoo Web Library (OWL) is a smallish (~<20kb gzipped) UI framework intended to be the basis for the Odoo Web Client. Owl is a modern framework, written in Typescript, taking the best ideas from React and Vue in a simple and consistent way. Owl's main features are:

  • a declarative component system,
  • a reactivity system based on hooks,
  • concurrent mode by default,
  • a store and a frontend router

Owl components are defined with ES6 classes, they use QWeb templates, an underlying virtual DOM, integrates beautifully with hooks, and the rendering is asynchronous.

Try it online! An online playground is available at https://odoo.github.io/owl/playground to let you experiment with the Owl framework. There are some code examples to showcase some interesting features.

Owl is currently stable. Possible future changes are explained in the roadmap.

Why Owl?

Why did Odoo decide to make Yet Another Framework? This is really a question that deserves a long answer. But in short, we believe that while the current state of the art frameworks are excellent, they are not optimized for our use case, and there is still room for something else.

If you are interested in a comparison with React or Vue, you will find some more additional information here.

Example

Here is a short example to illustrate interactive components:

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

class Counter extends Component {
  static template = xml`
    <button t-on-click="state.value++">
      Click Me! [<t t-esc="state.value"/>]
    </button>`;

  state = useState({ value: 0 });
}

class App extends Component {
  static template = xml`
    <div>
      <span>Hello Owl</span>
      <Counter />
    </div>`;

  static components = { Counter };
}

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

Note that the counter component is made reactive with the useState hook. Also, all examples here uses the xml helper to define inline templates. But this is not mandatory, many applications will load templates separately.

More interesting examples can be found on the playground application.

Design Principles

OWL is designed to be used in highly dynamic applications where changing requirements are common and code needs to be maintained by large teams.

  • XML based: templates are based on the XML format, which allows interesting applications. For example, they could be stored in a database and modified dynamically with xpaths.
  • templates compilation in the browser: this may not be a good fit for all applications, but if you need to generate dynamically user interfaces in the browser, this is very powerful. For example, a generic form view component could generate a specific form user interface for each various models, from a XML view.
  • no toolchain required: this is extremely useful for some applications, if, for various reasons (security/deployment/dynamic modules/specific assets tools), it is not ok to use standard web tools based on npm.

Owl is not designed to be fast nor small (even though it is quite good on those two topics). It is a no nonsense framework to build applications. There is only one way to define components (with classes). There is no black magic. It just works.

Documentation

A complete documentation for Owl can be found here:

Some of the most important pages are:

Installing Owl

Owl is available on npm and can be installed with the following command:

npm install @odoo/owl

If you want to use a simple <script> tag, the last release can be downloaded here:

License

OWL is LGPL licensed.

S
Description
OWL: A web framework for structured, dynamic and maintainable applications
Readme LGPL-3.0 27 MiB
Languages
TypeScript 87.3%
JavaScript 12.1%
CSS 0.5%
Python 0.1%