Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save BrianRosamilia/9fd236f10fd73240ca1549ecb9efff36 to your computer and use it in GitHub Desktop.
Save BrianRosamilia/9fd236f10fd73240ca1549ecb9efff36 to your computer and use it in GitHub Desktop.
Generate Code and assert its validty with Handlebars + Acorn + ava
let test = require('ava');
let handlebars = require('handlebars');
let acorn = require('acorn');
test('foo', t => {
let q = handlebars.compile('let x = {{{tt}}}');
let newAst = q({tt : "x => { console.log('Hello World!') }"});
console.log(newAst);
var ast = acorn.parse(newAst,{});
t.pass();
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment