Skip to content

Commit 2b0c363

Browse files
Documentation
1 parent f091f0a commit 2b0c363

File tree

1 file changed

+23
-2
lines changed

1 file changed

+23
-2
lines changed

README.md

+23-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
[![MIT License](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
1111

1212

13-
A minimalist *(⇡ check the install size)* one-way binding helper.
13+
A minimalist *(2889 bytes)* one-way binding helper.
1414

1515
## Usage
1616

@@ -124,9 +124,30 @@ model.items.push({
124124
await done() // Wait for the DOM update to be completed
125125
```
126126

127+
## Customizing
128+
129+
It is possible to tweak some settings with `punybind.use`, for instance :
130+
131+
```javascript
132+
// see https://www.npmjs.com/package/punyexpr
133+
const safebind = punybind.use({
134+
compiler: punyexpr
135+
})
136+
// safebind offers the same features as punybind
137+
const { model, done } = await safebind(document.body, {
138+
title: 'Hello World !',
139+
items: []
140+
})
141+
```
142+
143+
Available options :
144+
145+
* `compiler: (expression: string) => (context: object) => any`
146+
* Function that *compiles* the expression and return a function that evaluates it with the given context. Default compiler uses an eval-like syntax.
147+
127148
## Implementation notes
128149

129-
* The implementation is **not** compliant with [Content Security Policy](https://developer.mozilla.org/en-US/docs/Web/HTTP/CSP).
150+
* The default expression compiler implementation is **not** compliant with [Content Security Policy](https://developer.mozilla.org/en-US/docs/Web/HTTP/CSP).
130151
* **Only** properties coming from the contextual object can be used in evaluated expressions.
131152
* Bound elements are *hidden* under [`template` elements](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/template).
132153
* When any error occurs *(inconsistent binding, invalid syntax)*, the binding **silently** fails.

0 commit comments

Comments
 (0)