Files
owl/README.md
T

129 lines
4.5 KiB
Markdown
Raw Normal View History

<h1 align="center">🦉 <a href="https://odoo.github.io/owl/">Owl Framework</a> 🦉</h1>
2019-01-17 18:08:39 +01:00
2021-09-20 17:13:30 +02:00
[![License: LGPL v3](https://img.shields.io/badge/License-LGPL%20v3-blue.svg)](https://www.gnu.org/licenses/lgpl-3.0)
[![npm version](https://badge.fury.io/js/@odoo%2Fowl.svg)](https://badge.fury.io/js/@odoo%2Fowl)
[![Downloads](https://img.shields.io/npm/dm/@odoo%2Fowl.svg)](https://www.npmjs.com/package/@odoo/owl)
_Class based components with hooks, reactive state and concurrent mode_
**Try it online!** you can experiment with the Owl framework in an online [playground](https://odoo.github.io/owl/playground).
## Project Overview
The Odoo Web Library (Owl) is a smallish (~<20kb gzipped) UI framework built by
[Odoo](https://www.odoo.com/) for its products. Owl is a modern
2019-09-27 16:48:54 +02:00
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 fine grained reactivity system similar to Vue,
- hooks
- fragments
- asynchronous rendering
2019-04-23 11:46:08 +02:00
Owl components are defined with ES6 classes and xml templates, uses an
underlying virtual DOM, integrates beautifully with hooks, and the rendering is
2020-01-24 15:41:39 +01:00
asynchronous.
2019-09-27 16:48:54 +02:00
Quick links:
2020-01-24 15:41:39 +01:00
- [documentation](#documentation),
- [changelog](CHANGELOG.md) (from Owl 1.x to 2.x),
- [playground](https://odoo.github.io/owl/playground)
2020-01-24 15:41:39 +01:00
2019-06-14 15:24:04 +02:00
## Example
Here is a short example to illustrate interactive components:
2019-03-27 15:40:24 +01:00
```javascript
const { Component, useState, mount, xml } = owl;
2019-09-12 09:45:32 +02:00
class Counter extends Component {
static template = xml`
<button t-on-click="() => state.value = state.value + props.increment">
2019-09-12 09:45:32 +02:00
Click Me! [<t t-esc="state.value"/>]
</button>`;
2019-09-24 14:06:53 +02:00
state = useState({ value: 0 });
2019-03-27 15:40:24 +01:00
}
class Root extends Component {
2019-09-12 09:45:32 +02:00
static template = xml`
<span>Hello Owl</span>
<Counter increment="2"/>`;
2019-09-12 09:45:32 +02:00
2019-09-11 14:01:49 +02:00
static components = { Counter };
2019-08-28 12:10:46 +02:00
}
mount(Root, document.body);
```
2019-03-27 16:42:21 +01:00
2019-10-28 09:03:55 +01:00
Note that the counter component is made reactive with the [`useState` hook](doc/reference/hooks.md#usestate).
Also, all examples here uses the [`xml` helper](doc/reference/templates.md#inline-templates) to define inline templates.
2019-09-27 16:48:54 +02:00
But this is not mandatory, many applications will load templates separately.
2019-09-24 14:06:53 +02:00
2019-09-12 09:45:32 +02:00
More interesting examples can be found on the
2019-06-15 10:38:29 +02:00
[playground](https://odoo.github.io/owl/playground) application.
2019-03-27 15:40:24 +01:00
## Documentation
### Learning Owl
Are you new to Owl? This is the place to start!
- [Tutorial: create a TodoList application](doc/learning/tutorial_todoapp.md)
- [How to start an Owl project](doc/learning/quick_start.md)
- [How to test Components](doc/learning/how_to_test.md)
### Reference
- [Overview](doc/readme.md)
- [App](doc/reference/app.md)
- [Component](doc/reference/component.md)
- [Component Lifecycle](doc/reference/component.md#lifecycle)
- [Concurrency Model](doc/reference/concurrency_model.md)
2022-03-08 11:02:22 +01:00
- [Dev mode](doc/reference/app.md#dev-mode)
- [Dynamic sub components](doc/reference/component.md#dynamic-sub-components)
- [Environment](doc/reference/environment.md)
- [Error Handling](doc/reference/error_handling.md)
- [Event Handling](doc/reference/event_handling.md)
- [Form Input Bindings](doc/reference/input_bindings.md)
- [Fragments](doc/reference/templates.md#fragments)
- [Hooks](doc/reference/hooks.md)
- [Loading Templates](doc/reference/app.md#loading-templates)
- [Mounting a component](doc/reference/app.md#mount-helper)
- [Portal](doc/reference/portal.md)
- [Precompiling templates](doc/reference/precompiling_templates.md)
- [Props](doc/reference/props.md)
- [Props Validation](doc/reference/props.md#props-validation)
- [Reactivity](doc/reference/reactivity.md)
- [Rendering SVG](doc/reference/templates.md#rendering-svg)
- [Refs](doc/reference/refs.md)
- [Slots](doc/reference/slots.md)
- [Sub components](doc/reference/component.md#sub-components)
- [Sub templates](doc/reference/templates.md#sub-templates)
- [Templates (Qweb)](doc/reference/templates.md)
- [Translations](doc/reference/translations.md)
- [Utils](doc/reference/utils.md)
### Other Topics
- [Notes On Owl Architecture](doc/miscellaneous/architecture.md)
- [Comparison with React/Vue](doc/miscellaneous/comparison.md)
- [Why did Odoo build Owl?](doc/miscellaneous/why_owl.md)
- [Changelog (from owl 1.x to 2.x)](CHANGELOG.md)
- [Notes on compiled templates](doc/miscellaneous/compiled_template.md)
## Installing Owl
2019-03-27 15:40:24 +01:00
Owl is available on `npm` and can be installed with the following command:
2019-12-19 14:12:00 +01:00
```
npm install @odoo/owl
```
If you want to use a simple `<script>` tag, the last release can be downloaded here:
2019-03-27 15:40:24 +01:00
2021-12-07 15:32:05 +01:00
- [owl-1.4.10](https://github.com/odoo/owl/releases/tag/v1.4.10)