html-template-tag
Advanced tools
Comparing version 2.0.0 to 3.0.0
@@ -1,1 +0,1 @@ | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:true});function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}}var _htmlEs6cape=require("html-es6cape");var _htmlEs6cape2=_interopRequireDefault(_htmlEs6cape);exports["default"]=function(literals){for(var _len=arguments.length,substs=Array(_len>1?_len-1:0),_key=1;_key<_len;_key++){substs[_key-1]=arguments[_key]}return literals.raw.reduce(function(acc,lit,i){var subst=substs[i-1];if(Array.isArray(subst)){subst=subst.join("")}else if(acc.endsWith("$")){acc=acc.slice(0,-1)}else{subst=(0,_htmlEs6cape2["default"])(subst)}return acc+subst+lit})};module.exports=exports["default"]; | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:true});function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}}var _htmlEs6cape=require("html-es6cape");var _htmlEs6cape2=_interopRequireDefault(_htmlEs6cape);exports["default"]=function(literals){for(var _len=arguments.length,substs=Array(_len>1?_len-1:0),_key=1;_key<_len;_key++){substs[_key-1]=arguments[_key]}return literals.raw.reduce(function(acc,lit,i){var subst=substs[i-1];if(Array.isArray(subst)){subst=subst.join("")}else if(literals.raw[i-1]&&literals.raw[i-1].endsWith("$")){acc=acc.slice(0,-1)}else{subst=(0,_htmlEs6cape2["default"])(subst)}return acc+subst+lit})};module.exports=exports["default"]; |
{ | ||
"name": "html-template-tag", | ||
"version": "2.0.0", | ||
"version": "3.0.0", | ||
"description": "ES6 Tagged Template for compiling HTML template strings.", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
@@ -10,3 +10,3 @@ // Inspired on http://www.2ality.com/2015/01/template-strings-html.html#comment-2078932192 | ||
subst = subst.join(""); | ||
} else if (acc.endsWith('$')) { | ||
} else if (literals.raw[i - 1] && literals.raw[i - 1].endsWith("$")) { | ||
// If the interpolation is preceded by a dollar sign, | ||
@@ -13,0 +13,0 @@ // substitution is considered safe and will not be escaped |
@@ -39,2 +39,12 @@ import {expect} from "chai"; | ||
it("should escape HTML special characters if previous substituition ended with $", () => { | ||
let insertedDollar = "I :heart: $"; | ||
let unsafeString = " & €"; | ||
let emptyString = ""; | ||
expect(html`${insertedDollar}${unsafeString}!`).to.equal("I :heart: $ & €!"); | ||
expect(html`${insertedDollar}${emptyString}${unsafeString}!`).to.equal("I :heart: $ & €!"); | ||
expect(html`${insertedDollar}$${emptyString}${unsafeString}!`).to.equal("I :heart: $ & €!"); | ||
expect(html`$${insertedDollar}${emptyString}${unsafeString}!`).to.equal("I :heart: $ & €!"); | ||
}) | ||
it("should generate valid HTML with an array of values", () => { | ||
@@ -41,0 +51,0 @@ let names = ["Megan", "Tiphaine", "Florent", "Hoan"]; |
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
8845
62