From b440eec373bc7e5aaefd84bf8192c78fe119590a Mon Sep 17 00:00:00 2001 From: DarkWiiPlayer Date: Tue, 23 Nov 2021 16:27:25 +0100 Subject: [PATCH] Add text wrapper to skooma.js --- skooma.js | 2 ++ skooma.md | 7 +++++++ 2 files changed, 9 insertions(+) diff --git a/skooma.js b/skooma.js index e3d8ef3..8fa4f92 100644 --- a/skooma.js +++ b/skooma.js @@ -87,3 +87,5 @@ export const handle = fn => event => { event.preventDefault(); return fn(event) export const html = nameSpacedProxy({nameFilter: name => name.replace(/([a-z])([A-Z])/g, "$1-$2").toLowerCase()}) export const svg = nameSpacedProxy({xmlns: "http://www.w3.org/2000/svg"}) + +export const text = (data="") => document.createTextNode(data) diff --git a/skooma.md b/skooma.md index ff0ca43..3ad4623 100644 --- a/skooma.md +++ b/skooma.md @@ -38,6 +38,13 @@ html.div({foo: "bar"}, {foo: false}) html.div(dataset: {foo: 1, bar: 2}) // Creates a
with the attributes "data-foo" and "data-bar" set to 1 and 2 html.div(style: {color: 'red'}) // Creates a
with the "style" attribute set to "color: red" ``` +```js +text("Hello, World") +// Wraps document.createTextNode +text() +// Defaults to empty string +``` + Generators can be called with many arguments. Arrays get iterated recursively as if they were part of a flat argument list.