From f1a18efd8b50ac99833199f40b82b06150a5958e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=A9ry=20Debongnie?= Date: Thu, 14 Mar 2019 14:23:27 +0100 Subject: [PATCH] update component and qweb doc --- doc/component.md | 29 ++++++++++++++++++++++++++++- doc/qweb.md | 26 +++++++++++++++++++++++++- 2 files changed, 53 insertions(+), 2 deletions(-) diff --git a/doc/component.md b/doc/component.md index 763dcf60..cbc6ad5f 100644 --- a/doc/component.md +++ b/doc/component.md @@ -1,3 +1,30 @@ # Component -hey +Components are the reusable, composable widgets. They are designed to be low +level, to be declarative, and with asynchronous rendering. + +For example: + +```javascript +export class Counter extends Component { + inlineTemplate = ` +
+ + Value: + +
`; + + state = { + counter: 0 + }; + + constructor(parent, props) { + super(parent, props); + this.state.counter = props.initialState || 0; + } + + increment(delta) { + this.updateState({ counter: this.state.counter + delta }); + } +} +``` diff --git a/doc/qweb.md b/doc/qweb.md index b7c29ee8..7ee88951 100644 --- a/doc/qweb.md +++ b/doc/qweb.md @@ -1,3 +1,27 @@ # QWeb -hey +QWeb is a template specification. The QWeb class in this repository is: + +- an implementation of the QWeb specification +- which outputs a virtual dom instead of a string +- and extended with a few extra directives + +## QWeb Specification + +add here a full description of what QWeb is supposed to be, with some examples + +## QWeb Implementation + +```javascript +var qweb = new QWeb(); +qweb.addTemplate("sometemplate", '
hello
'); + +// result is a vnode which represent
hello world
+result = qweb.render("sometemplate", { name: "world" }); +``` + +## QWeb extensions + +- t-on directive +- t-widget, t-props, t-key +- t-ref