Last active
February 24, 2023 07:29
-
-
Save ivanjeremic/25e5016da69e0894366c7a5534787dac to your computer and use it in GitHub Desktop.
html template literal
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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