UNPKG

html-template-tag

Version:

ES6 Tagged Template for compiling HTML template strings.

2 lines (1 loc) 1.16 kB
import t from"html-es6cape";import{htmlElementAttributes as e}from"html-element-attributes";var n=Object.values(e).flat();var r=["action","archive","background","cite","classid","codebase","content","data","dynsrc","formaction","href","icon","imagesrcset","longdesc","lowsrc","manifest","nohref","onload","poster","popovertargetaction","profile","src","srcset","style","usemap"];function a(e){for(var a=[],o=1;o<arguments.length;o++)a[o-1]=arguments[o];return e.raw.reduce(function(o,i,s){var c=!e.raw[s-1].endsWith("$"),l=a[s-1];return Array.isArray(l)?l=l.join(""):c?l=t(l):o=o.slice(0,-1),function(t){return n.some(function(e){return t.endsWith("".concat(e,"="))})}(o)&&(o+='"',i='"'+i),function(t){return r.some(function(e){return t.endsWith("".concat(e,"="))||t.endsWith("".concat(e,'="'))})}(o)&&c&&(console.warn("[html-template-tag] Trying to interpolate inside an URI attribute. This can lead to security vulnerabilities. The interpolation has been removed. If you are sure you want to interpolate inside an URI attribute, please escape this interpolation with an extra '$' sign in front of it.",{acc:o,subst:l,lit:i}),l=""),o+l+i})}export{a as default};