For a static site generator I want to know all the files a Crinja template includes or extends so I can mark the template as changed.
Currently I am doing this, which works but doesn’t catch them all:
deps = [] of String
nodes = Crinja::Template.new(source).nodes.@children
nodes.select(Crinja::AST::TagNode) \
.select { |n| n.@name == "include" }.each { |n|
deps << "kv://#{n.@arguments[0].value}"
}
I can’t figure out how to visit all the tree and catch all the TagNodes. I have looked at the source code and I guess some kind of Visitor? Any help appreciated.
PS: I also would love to be able to get a list of all the names of filters used in a template for similar reasons.