You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
24 lines
511 B
JavaScript
24 lines
511 B
JavaScript
import _ from 'lodash';
|
|
|
|
export default function tpl(pieces, ...substitutions) {
|
|
let result = pieces[0];
|
|
for (let i = 0; i < substitutions.length; ++i) {
|
|
const subst = substitutions[i];
|
|
let substHtml;
|
|
if (typeof subst === 'object' && subst.templateRaw) {
|
|
substHtml = subst.html;
|
|
} else {
|
|
substHtml = _.escape(String(subst));
|
|
}
|
|
result += substHtml + pieces[i + 1];
|
|
}
|
|
return result;
|
|
}
|
|
|
|
export function rawHtml(html) {
|
|
return {
|
|
templateRaw: true,
|
|
html,
|
|
};
|
|
}
|