string-tags
Advanced tools
Comparing version 0.1.0 to 0.1.1
{ | ||
"name": "string-tags", | ||
"version": "0.1.0", | ||
"version": "0.1.1", | ||
"description": "common tags for es6 string template", | ||
@@ -5,0 +5,0 @@ "repository": { |
@@ -5,17 +5,24 @@ | ||
```javascript | ||
const tags = require('../index.js'); | ||
const tags = require('../index.js'); | ||
let reg1 = tags.regexp`\\\(${"*("}\\\gi`; | ||
let input = "*)"; | ||
let reg1 = tags.regexp`\\\(${input}\gi`; | ||
// this is same as | ||
reg1 = /\\\(\*\)/gi; | ||
or | ||
reg1 = new RegExp("\\\\\\(\\*\\)", "gi"); | ||
// use string-tags for regexp only when embedded expressions is needed | ||
``` | ||
this is same as `reg1 = /\\\(\*\(\\/gi;`. use string-tags for regexp only embedded expressions is needed | ||
### XML | ||
```javascript | ||
const tags = require('../index.js'); | ||
const tags = require('../index.js'); | ||
let xml1 = tags.xml`<a>${'&<>'}</a>`; // escape the xml string | ||
let dom = tags.dom_xml`<a>${'&<>'}</a>`; // output a document instead of string | ||
let input = "&<>"; | ||
let xml1 = tags.xml`<a>${input}</a>`; // escape the xml string | ||
let dom = tags.dom_xml`<a>${input}</a>`; // output a document instead of string | ||
``` |
@@ -5,4 +5,4 @@ const assert = require('assert'); | ||
let reg1 = tags.regexp`\\\(${"*("}\\\gi`; | ||
let reg2 = /\\\(\*\(\\/gi; | ||
let reg1 = tags.regexp`\\\(${"*)"}\\\gi`; | ||
let reg2 = /\\\(\*\)\\/gi; | ||
@@ -9,0 +9,0 @@ assert.equal(reg1.source, reg2.source, 'regexp source'); |
16485
27