Created
September 29, 2017 09:50
-
-
Save henrikhaugboelle/d07dbe41726b448b337c420027c8e55e 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
const input = require('./my-thing.gui') | |
const parse = (obj, html = "") => { | |
Object.keys(obj).forEach(key => { | |
const element = obj[key] | |
switch (element.type) { | |
case 'button': | |
html += `<button>${parse(element.children, html)}</button>` | |
break; | |
case 'input': | |
html += `<input />` | |
break; | |
} | |
return html | |
}) | |
} | |
const output = parse(input) | |
Fs.writeFileSync('./my-thing.html', output) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment