@cfx-kit/wallet-avatar
Version:
| Statements | Branches | Functions | Lines | | --------------------------- | ----------------------- | ------------------------- | ----------------- | |  {
const map = {
'&': '&',
'<': '<',
'>': '>',
'"': '"',
"'": ''',
};
return `${html}`.replace(/[&<>"']/g, (i) => {
return map[i] || i;
});
}
export function valueToHTML(v) {
if (v instanceof HTMLTemplate) {
return v.toString();
}
if (Array.isArray(v)) {
return v.map((i) => valueToHTML(i)).join('');
}
if ((typeof v === 'boolean' && v === false) || v === undefined || v === null) {
return '';
}
return escapeHTML(v);
}
export class HTMLTemplate {
constructor(strings, values) {
this.strings = strings;
this.values = values;
}
getHTML() {
const { strings, values } = this;
let str = strings[0];
for (let i = 1; i < strings.length; i++) {
const v = values[i - 1];
str += `${valueToHTML(v)}${strings[i]}`;
}
return str;
}
toString() {
return this.getHTML();
}
}
export default function html(strings, ...values) {
return new HTMLTemplate(strings, values);
}
//# sourceMappingURL=html.js.map