Skip to content

Commit c4727b2

Browse files
committed
✨ added mnml.text macro for generating text nodes
1 parent 33c02a4 commit c4727b2

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/mnml.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,17 @@ export const mnml = (() => {
5252
);
5353
};
5454

55+
const text = (strings: TemplateStringsArray, ...values: any[]): Text => {
56+
const text = document.createTextNode(
57+
strings
58+
.map((str, index) => {
59+
return str + (typeof values[index] === "undefined" ? "" : values[index]);
60+
})
61+
.join("")
62+
);
63+
return text;
64+
};
65+
5566
const find = (elem: HTMLElement | string, selector: string): HTMLElement | null => {
5667
if (typeof elem === "string") {
5768
selector = elem;

0 commit comments

Comments
 (0)