Advertisement
Guest User

Untitled

a guest
Jan 27th, 2015
191
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.70 KB | None | 0 0
  1. var plastiq = require('plastiq');
  2. var h = plastiq.html;
  3. var pogo = require('pogo');
  4. var code = "h 'h1' 'Edit me'";
  5.  
  6. function render(model) {
  7. return h('div',
  8. h('textarea', {
  9. style: textAreaStyle,
  10. binding: [model, 'code'],
  11. attributes: { autofocus: true }
  12. }),
  13. h('#print', evalPogo(model.code))
  14. );
  15. }
  16.  
  17. function evalPogo(code) {
  18. try {
  19. return eval(pogo.compile(code, { inScope: false }));
  20. } catch (e) {
  21. return h("pre.error", "ERROR: ", e.toString());
  22. }
  23. }
  24.  
  25. var textAreaStyle = {
  26. width: '80%',
  27. height: '200px',
  28. padding: '5px',
  29. fontFamily: "'Source Code Pro', Monaco, Consolas, monospace",
  30. fontSize: '15px'
  31. };
  32.  
  33. plastiq.attach(document.body, render, { code: code });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement