class

Crinit::TokenEngine

Inherits Reference < Object

Evaluates and interpolates substitution tokens across file contents and paths.

Constants

ESCAPED_CLOSE = "\u0000CRINIT_ESC_CLOSE\u0000"
ESCAPED_OPEN = "\u0000CRINIT_ESC_OPEN\u0000"
TOKEN_REGEX = /\{\{([a-zA-Z0-9_]+)\}\}/

Constructors

from_config(config : Config) : self

Builds a standard dictionary from Crinit::Config.

Source
new(dictionary : Hash(String, String) = Hash(String, String).new)
Source

Class methods

module_name(name : String) : String

Converts project identifiers to valid Crystal module names. Hyphens indicate nested namespaces (e.g. foo-bar -> Foo::Bar). Underscores convert to PascalCase within the same namespace (e.g. foo_bar -> FooBar).

Source

Instance methods

dictionary
Source
render_content(content : String) : String

Renders a string template, substituting recognized tokens while preserving unmapped macro delimiters and unescaping explicit macro escapes.

Source
render_path(path : Path) : Path

Interpolates tokens within a relative or absolute filesystem Path.

Source