Skip to content

Instantly share code, notes, and snippets.

@joshski
Last active August 29, 2015 14:14
Show Gist options
  • Save joshski/56aac6c5a65f351fcac1 to your computer and use it in GitHub Desktop.
Save joshski/56aac6c5a65f351fcac1 to your computer and use it in GitHub Desktop.
Plastiq/Pogo REPL
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