escape-html-template-tag
Advanced tools
Comparing version 1.0.0 to 1.0.1
{ | ||
"name": "escape-html-template-tag", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"description": "Tag literal strings with this function to html escape interpolated values", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -66,2 +66,27 @@ # escape-html-template-tag | ||
// </div> | ||
``` | ||
### Compose templates easily with functions | ||
```js | ||
const html = require('escape-html-template-tag') | ||
const anchor = (text, href) => html`<a href="${href}">${text}</a>` | ||
const list = items => html` | ||
<ul> | ||
${items.map(item => html`<li>${item}</li>`)} | ||
</ul> | ||
` | ||
const navigation = list( | ||
anchor('Home', '/home'), | ||
anchor('About', '/about'), | ||
anchor('Blog', '/blog') | ||
); | ||
// <ul> | ||
// <li><a href="/home">Home</a></li> | ||
// <li><a href="/about">About</a></li> | ||
// <li><a href="/blog">Blog</a></li> | ||
// </ul> | ||
``` |
@@ -32,2 +32,1 @@ const assert = require('assert') | ||
assert.strictEqual(String(escapeHtml`${escapeHtml.safe(escapeHtml`<a>`)}`), '<a>') | ||
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
5285
91