Last active
August 29, 2015 14:14
-
-
Save joshski/56aac6c5a65f351fcac1 to your computer and use it in GitHub Desktop.
Plastiq/Pogo REPL
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
var plastiq = require('plastiq'); | |
var h = plastiq.html; | |
var pogo = require('pogo'); | |
var code = "h 'h1' 'Edit me'"; | |
function render(model) { | |
return h('div', | |
h('textarea#read', { | |
style: textAreaStyle, | |
binding: [model, 'code'], | |
attributes: { autofocus: true } | |
}), | |
h('#print', evalPogo(model.code)) | |
); | |
} | |
function evalPogo(code) { | |
try { | |
return eval(pogo.compile(code, { inScope: false })); | |
} catch (e) { | |
return h("pre.error", "ERROR: ", e.toString()); | |
} | |
} | |
var textAreaStyle = { | |
width: '80%', | |
height: '200px', | |
padding: '5px', | |
fontFamily: "'Source Code Pro', Monaco, Consolas, monospace", | |
fontSize: '15px' | |
}; | |
plastiq.attach(document.body, render, { code: code }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment