class

Hwaro::Core::Build::TemplateDeps

Inherits Reference / Object

Constants

FROM_ARG_RE = /\A\s*(?:"([^"]+)"|'([^']+)')\s+import\s+.+\z/m
IMPORT_ARG_RE = /\A\s*(?:"([^"]+)"|'([^']+)')\s+as\s+\w+\s*(?:with(?:out)?\s+context\s*)?\z/
INCLUDE_ARG_RE = /\A\s*(?:"([^"]+)"|'([^']+)')\s*(?:ignore\s+missing\s*)?(?:with(?:out)?\s+context\s*)?\z/

Per-tag argument shapes where the template name is a plain string literal. The literal must account for the ENTIRE argument (modulo the tag's own keywords) — a leading literal in an expression like {% include "partials/" ~ name %} must NOT count as static.

REFERENCE_TAG_RE = /\{%-?\s*(extends|include|import|from)\b\s*(.+?)\s*-?%\}/m

{% extends "base.html" %}, {% include 'partials/head.html' %}, {% import "macros.html" as m %}, {% from "macros.html" import x %}

\b\s* (not \s+) after the keyword: Crinja happily parses {% include"x.html" %} with no space, and a tag this regex fails to see entirely never reaches the safe @dynamic = true fallback — it just silently drops the dependency edge and the included template's edits stop re-rendering its dependents during serve.

Constructors

new(templates : Hash(String, String))
Source

Instance methods

closure(name : String) : Set(String)

Transitive dependency set of a template, including itself. Unknown references stay in the set: they hash as "absent", so a template appearing later changes the closure hash and re-renders.

Source
closure_hash(entry_template : String, shortcode_templates : Set(String) = Set(String).new) : String

Stable fingerprint of everything that influences a page's rendered template output: the entry template's closure plus the closures of every shortcode template the page content invokes.

Memoized: sites have a handful of distinct (entry template, shortcode set) combinations but compute this once or twice per page on cached builds. The memo lives for this instance's lifetime, which is exactly one template (re)load — invalidation is automatic.

Source
dependents_closure(changed : Set(String)) : Set(String)

All templates whose closure intersects changed — i.e. every template that (transitively) extends, includes, or imports one of the changed templates, plus the changed templates themselves.

Source
dynamic?

True when any reference could not be resolved statically — the graph is incomplete and callers must treat every template change as affecting every page.

Source
shortcode_names

Bare names of user shortcode templates (templates/shortcodes/*).

Source
shortcodes_used_in(text : String) : Set(String)

Templates the page's content references via shortcode calls.

Source