Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
Updates README.md with javascript object syntax described here: choojs#164 (comment)
  • Loading branch information
bennlich committed Oct 11, 2022
1 parent c90ad29 commit f13dac5
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,19 @@ var el = html`
document.querySelector('ul').appendChild(el)
```

### Conditional attributes

Use a javascript object to conditionally add HTML attributes.

```js
var html = require('nanohtml')

var customAttr = isFuzzy ? { 'data-hand-feel': 'super-fuzzy' } : {}
var el = html`
<div ${ customAttr }></div>
`
```

## Static optimizations
Parsing HTML has significant overhead. Being able to parse HTML statically,
ahead of time can speed up rendering to be about twice as fast.
Expand Down

0 comments on commit f13dac5

Please sign in to comment.