diff options
| author | s-ol <s-ol@users.noreply.github.com> | 2019-10-29 13:18:16 +0000 |
|---|---|---|
| committer | s-ol <s-ol@users.noreply.github.com> | 2019-10-29 13:18:16 +0000 |
| commit | d9eafa21ad1d6ad340b5744d69e9fc68ce2083cb (patch) | |
| tree | c5e4c1ce74094b5feebbca944e316fb2833fe027 /root/sandbox/javascript | |
| parent | small styling fixes (diff) | |
| download | mmm-d9eafa21ad1d6ad340b5744d69e9fc68ce2083cb.tar.gz mmm-d9eafa21ad1d6ad340b5744d69e9fc68ce2083cb.zip | |
add sandbox
Diffstat (limited to 'root/sandbox/javascript')
| -rw-r--r-- | root/sandbox/javascript/description: text$markdown.md | 1 | ||||
| -rw-r--r-- | root/sandbox/javascript/text$javascript -> mmm$dom.js | 24 |
2 files changed, 25 insertions, 0 deletions
diff --git a/root/sandbox/javascript/description: text$markdown.md b/root/sandbox/javascript/description: text$markdown.md new file mode 100644 index 0000000..eb0ca7c --- /dev/null +++ b/root/sandbox/javascript/description: text$markdown.md @@ -0,0 +1 @@ +an example of how to use JS to create (dynamic) DOM / mmmfs content diff --git a/root/sandbox/javascript/text$javascript -> mmm$dom.js b/root/sandbox/javascript/text$javascript -> mmm$dom.js new file mode 100644 index 0000000..58deb23 --- /dev/null +++ b/root/sandbox/javascript/text$javascript -> mmm$dom.js @@ -0,0 +1,24 @@ +// a little helper function for creating DOM elements +const e = (elem, children) => { + const node = document.createElement(elem); + + if (typeof children === 'string') + node.innerText = children; + else + children.forEach(child => node.appendChild(child)); + + return node; +}; + +/* creating the equivalent of the following HTML directly as DOM content: + * + * <article> + * <h1>JavaScript</h1> + * <p>...</p> + * </article> + */ + +return e('article', [ + e('h1', 'JavaScript'), + e('p', 'JavaScript is supported natively in the browser but is not currently pre-rendered on the server.'), +]); |
