Skip to content

Instantly share code, notes, and snippets.

@evanxg852000
Created December 24, 2018 15:12
Show Gist options
  • Save evanxg852000/a8a03f5150f117af0792df7eb75ea323 to your computer and use it in GitHub Desktop.
Save evanxg852000/a8a03f5150f117af0792df7eb75ea323 to your computer and use it in GitHub Desktop.
class Templater {
...
generate(ast){
return `module.exports = function (context) {
context = context || {}
for(let varname of Object.keys(context)){
this[varname]= context[varname]
}
let __njsOutput = ''
${ast.generate()}
return __njsOutput
}`
}
...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment