module

Plombir::Template::Errors

Builds Error diagnostics. Bodies stay stable — specs pin their wording — while fail appends the source-line footer.

Constants

FILTER_NAMES = ["escape", "strip_html", "truncate", "date", "slugify", "jsonify", "asset_url"]

Filters the engine applies in {{ }}. Shared by the unknown-filter diagnostic and its hint, like TAG_NAMES.

TAG_NAMES = ["if", "elsif", "for", "include", "component", "else", "end"]

Names the engine understands in {% %}. Shared by the unknown-tag diagnostic and its closest-name hint so the two can never drift apart.

Class methods

closest(word : String, candidates : Array(String)) : String | Nil

The nearest candidate to word, or nil when nothing is near enough: at most 3 edits and strictly fewer than the word's length, so xyz never suggests end. Ties prefer the longest shared prefix — typos usually keep the start of the word, so endfor suggests end, not for.

Source
collection_message(file : String, line : Int32, column : Int32, name : String) : String
Source
component_message(file : String, line : Int32, column : Int32, name : String, available : Array(String)) : String
Source
component_syntax_message(file : String, line : Int32, column : Int32) : String
Source
date_message(file : String, line : Int32, column : Int32, value : String) : String
Source
distance(a : String, b : String) : Int32

Edit distance between two words (insert, delete, and substitute cost 1). Hand-rolled two-row table: tag and filter names are a few chars, so this is plenty and dependency-free.

Source
else_message(file : String, line : Int32, column : Int32) : String
Source
elsif_message(file : String, line : Int32, column : Int32) : String
Source
elsif_order_message(file : String, line : Int32, column : Int32) : String
Source
fail(file : String, lines : Array(String), line : Int32, column : Int32, body : String) : NoReturn

Raises an Error for file at line:column, appending the offending source line from lines (the template split on \n) to body.

Source
filter_arg_message(file : String, line : Int32, column : Int32, name : String) : String
Source
filter_message(file : String, line : Int32, column : Int32, name : String, available : Array(String) = FILTER_NAMES) : String
Source
for_message(file : String, line : Int32, column : Int32) : String
Source
if_message(file : String, line : Int32, column : Int32) : String
Source
include_depth_message(file : String, line : Int32, column : Int32, chain : Array(String), max : Int32) : String
Source
include_message(file : String, line : Int32, column : Int32, name : String, available : Array(String)) : String
Source
include_syntax_message(file : String, line : Int32, column : Int32) : String
Source
nesting_message(file : String, line : Int32, column : Int32, max : Int32) : String
Source
prop_message(file : String, line : Int32, column : Int32, component : String, name : String, call_site : String) : String
Source
snippet(lines : Array(String), line : Int32) : String

The offending source line, e.g. 12 │ {{ title }}. A missing line (empty input) renders empty — never a crash.

Source
stray_message(file : String, line : Int32, column : Int32, tag : String) : String
Source
suggest(word : String, candidates : Array(String)) : String | Nil

A ready-to-print hint line for the nearest candidate, or nil. Generic over candidates so the future unknown-filter diagnostic reuses it unchanged.

Source
unclosed_message(file : String, line : Int32, column : Int32, opener : String) : String
Source
unknown_message(file : String, line : Int32, column : Int32, tag : String) : String
Source
unterminated_message(file : String, line : Int32, column : Int32) : String
Source
variable_message(file : String, line : Int32, column : Int32) : String
Source