[IMP] app: add global values at compile time

This commit, add a new configuration on the App: globalValues.
It's a global object of elements available at compilations.

For instance:
```js
    const app = new App(SomeComponent, {
      globalValues: {
        plop: (string: any) => {
          steps.push(string);
        },
      },
    });
```

The plop function will be available at the compilation, so it can be
used on the templates :
```xml
<div t-on-click="() => __globals__.plop('click')" class="my-div"/>
```
This commit is contained in:
Jorge Pinna Puissant
2024-11-12 16:37:03 +01:00
committed by Géry Debongnie
parent 7e687234bf
commit 6b2486473f
8 changed files with 50 additions and 3 deletions
+1
View File
@@ -68,6 +68,7 @@ The `config` object is an object with some of the following keys:
whenever it encounters a component that does not provide a [static props description](props.md#props-validation).
- **`customDirectives (object)`**: if given, the corresponding function on the object will be called
on the template custom directives: `t-custom-*` (see [Custom Directives](templates.md#custom-directives)).
- **`globalValues (object)`**: Global object of elements available at compilations.
## `mount` helper