shawnbot / meta-template

:sparkles: Automagically convert Nunjucks templates into a variety of other formats!
52 stars 9 forks source link

Reverse-engineer templates? #1

Open shawnbot opened 7 years ago

shawnbot commented 7 years ago

What if you could use meta-template to figure out all of the variables a given template expects? All of the following should be theoretically possible to figure out from the AST:

The other way that this could work is as a validation tool in which you would provide, say, the JSON Schema for the data a template expects (which would serve as the template's "API"), and then validate a template against that schema to confirm that it doesn't attempt to access invalid properties, attempt to iterate over primitives, etc.