Skip to content

Instantly share code, notes, and snippets.

@henrikhaugboelle
Created September 29, 2017 09:50
Show Gist options
  • Save henrikhaugboelle/d07dbe41726b448b337c420027c8e55e to your computer and use it in GitHub Desktop.
Save henrikhaugboelle/d07dbe41726b448b337c420027c8e55e to your computer and use it in GitHub Desktop.
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