diff --git a/README.md b/README.md index 3d9c27c..8f7eb0d 100644 --- a/README.md +++ b/README.md @@ -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` +
+` +``` + ## 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.