class

Templates::DependencyVisitor

Inherits Crinja::Visitor < Reference < Object

A visitor over a parsed template's AST that collects references to other templates, following crinja's visitor pattern (see Crinja::Visitor and Visitor::Inspector). The parser AST has no accept method, so this visitor owns the traversal itself.

Only statically resolvable references (string literals) are collected: a dynamic reference like {% include somevar %} can't be tracked without rendering, so it is skipped (and logged at debug level) instead of producing a bogus dependency.

Constants

REFERENCE_TAGS = {"include", "extends", "import", "from"}

Tags whose string literal arguments name other templates

Constructors

new(current_template : String)
Source

Instance methods

dependencies(source : String) : Array(String)

Parse source and return the kv:// keys of all referenced templates, deduplicated and sorted. Self-references (a template including itself) are skipped.

Source
visit(node : AST::NodeList)
Source
visit(node : AST::TagNode)
Source
visit(node : AST::TemplateNode)
Source

Nested types