[IMP] slots: add new t-set-slot directive

This new t-set-slot directive is meant to replace t-set when we need to
define the content of a sub slot. All new code should use that
directive.

The old t-set directive is still supported for now, but this should be
removed when we publish Owl 2.0.
This commit is contained in:
Géry Debongnie
2020-04-06 15:29:54 +02:00
committed by aab-odoo
parent ddf30a8a97
commit ae172d42e7
6 changed files with 164 additions and 21 deletions
+6 -3
View File
@@ -37,16 +37,16 @@ rendering context.
</div>
```
Slots are defined by the caller, with the `t-set` directive:
Slots are defined by the caller, with the `t-set-slot` directive:
```xml
<div t-name="SomeComponent">
<div>some component</div>
<Dialog title="Some Dialog">
<t t-set="content">
<t t-set-slot="content">
<div>hey</div>
</t>
<t t-set="footer">
<t t-set-slot="footer">
<button t-on-click="doSomething">ok</button>
</t>
</Dialog>
@@ -57,6 +57,9 @@ In this example, the component `Dialog` will render the slots `content` and `foo
with its parent as rendering context. This means that clicking on the button
will execute the `doSomething` method on the parent, not on the dialog.
Note: Owl previously used the `t-set` directive to define the content of a slot.
This is deprecated and should no longer be used in new code.
## Reference
Default slot: the first element inside the component which is not a named slot will