Skip to content

Commit f13dac5

Browse files
authored
Update README.md
Updates README.md with javascript object syntax described here: choojs#164 (comment)
1 parent c90ad29 commit f13dac5

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

README.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,19 @@ var el = html`
117117
document.querySelector('ul').appendChild(el)
118118
```
119119

120+
### Conditional attributes
121+
122+
Use a javascript object to conditionally add HTML attributes.
123+
124+
```js
125+
var html = require('nanohtml')
126+
127+
var customAttr = isFuzzy ? { 'data-hand-feel': 'super-fuzzy' } : {}
128+
var el = html`
129+
<div ${ customAttr }></div>
130+
`
131+
```
132+
120133
## Static optimizations
121134
Parsing HTML has significant overhead. Being able to parse HTML statically,
122135
ahead of time can speed up rendering to be about twice as fast.

0 commit comments

Comments
 (0)