module

Plombir::Template::Parser

Constants

MAX_NESTING = 100

Caps {% if %} / {% for %} nesting. Layouts nest a handful of levels; past this the input is runaway, and failing here keeps both the parser and the renderer's recursion shallow.

Class methods

elsif_tag?(text : String) : Bool

An {% elsif %} opener: exactly elsif or elsif <name>. Name validity is checked when the branch itself parses.

Source
name?(text : String) : Bool

A dotted lookup name: title, post.title. Flat contexts mean dots never traverse — the whole name is one key.

Source
parse(tokens : Array(Lexer::Token), file : String = "<input>", lines : Array(String) = [] of String) : Array(AST::Node)

Parses tokens (from Lexer.tokenize) into a node list. lines is the template split on \n, used for the source-line footer in diagnostics.

source = "{% if x %}y{% end %}"
tokens = Lexer.tokenize(source)
Parser.parse(tokens, "page.html", source.split('\n')).size # => 1
Source
partial_name?(text : String) : Bool

A partial or component name: flat basenames only (header, post-card, PostCard). No slashes or dots — partials live beside the layouts that use them, components under components/, so .. can never escape either directory.

Source
plain_name?(text : String) : Bool

A bare loop variable: post in {% for post in posts %}. Dots are rejected — post.title is read off the row, never bound.

Source