Created
March 17, 2026 20:30
-
-
Save souporserious/adfc4c68e5a369bcc54e43504c124ca3 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| /** | |
| * @param {TemplateStringsArray} strings | |
| * @param {...any} values | |
| * @returns {DocumentFragment} | |
| */ | |
| function html(strings, ...values) { | |
| let out = '' | |
| for (let index = 0; index < strings.length; index++) { | |
| out += strings[index] | |
| if (index < values.length) { | |
| const value = values[index] | |
| out += | |
| value == null | |
| ? '' | |
| : Array.isArray(value) | |
| ? value.join('') | |
| : String(value) | |
| } | |
| } | |
| const template = document.createElement('template') | |
| template.innerHTML = out.trim() | |
| return template.content | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment