Skip to content

Instantly share code, notes, and snippets.

@ivanjeremic
Last active February 24, 2023 07:29
Show Gist options
  • Save ivanjeremic/25e5016da69e0894366c7a5534787dac to your computer and use it in GitHub Desktop.
Save ivanjeremic/25e5016da69e0894366c7a5534787dac to your computer and use it in GitHub Desktop.
html template literal
export function html(literals: { raw: any }, ...vars: any[]) {
let raw = literals.raw,
HTMLprecompiled = "",
i = 1,
len = arguments.length,
str,
variable;
while (i < len) {
str = raw[i - 1];
variable = vars[i - 1];
HTMLprecompiled += str + variable;
i++;
}
HTMLprecompiled += raw[raw.length - 1];
return HTMLprecompiled;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment