This might be a stupid question but is it possible to get a list of all the variables in a template?
Unfortunately it isn't possible right now.
Though, it is possible to do in Jinja2, related issue can be found here #973. Maybe one day Nunjucks will get that feature too.
After looking at the code, I think it's possible to do what I need. I simply need to build something to traverse the ast and return only the variables.
var c = new Compiler();
var src = 'hello {% filter title %}' +
'Hello madam how are you' +
'{% endfilter %}'
var ast = transformer.transform(parser.parse(src));
// nodes.printNodes(ast);
If you will come up with working solution, don't forget to post it here :) I think to some people it might be useful.
+1 This would be useful for me.
Most helpful comment
+1 This would be useful for me.