mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-01-31 19:02:59 +01:00
docs: Revise clientVars
documentation
This commit is contained in:
parent
2e2cb38225
commit
f8a9cd4bad
1 changed files with 8 additions and 10 deletions
|
@ -617,14 +617,14 @@ is sent to the client. Plugins can use this hook to manipulate the
|
||||||
configuration. (Example: Add a tracking ID for an external analytics tool that
|
configuration. (Example: Add a tracking ID for an external analytics tool that
|
||||||
is used client-side.)
|
is used client-side.)
|
||||||
|
|
||||||
The clientVars function must return a Promise that resolves to an object (or
|
You can manipulate `clientVars` in two different ways:
|
||||||
null/undefined) whose properties will be merged into `context.clientVars`.
|
* Return an object. The object will be merged into `clientVars` via
|
||||||
Returning `callback(value)` will return a Promise that is resolved to `value`.
|
`Object.assign()`, so any keys that already exist in `clientVars` will be
|
||||||
|
overwritten by the values in the returned object.
|
||||||
You can modify `context.clientVars` to change the values sent to the client, but
|
* Modify `context.clientVars`. Beware: Other plugins might also be reading or
|
||||||
beware: async functions from other clientVars plugins might also be reading or
|
manipulating the same `context.clientVars` object. To avoid race conditions,
|
||||||
manipulating the same `context.clientVars` object. For this reason it is
|
you are encouraged to return an object rather than modify
|
||||||
recommended you return an object rather than modify `context.clientVars`.
|
`context.clientVars`.
|
||||||
|
|
||||||
If needed, you can access the user's account information (if authenticated) via
|
If needed, you can access the user's account information (if authenticated) via
|
||||||
`context.socket.client.request.session.user`.
|
`context.socket.client.request.session.user`.
|
||||||
|
@ -645,8 +645,6 @@ exports.clientVars = (hookName, context, callback) => {
|
||||||
};
|
};
|
||||||
```
|
```
|
||||||
|
|
||||||
This can be accessed on the client-side using `clientVars.currentYear`.
|
|
||||||
|
|
||||||
## getLineHTMLForExport
|
## getLineHTMLForExport
|
||||||
Called from: src/node/utils/ExportHtml.js
|
Called from: src/node/utils/ExportHtml.js
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue