KrikriJinja
Constants
Prefix marking a string as the decimal text of an integer too wide for Int64 (RSA moduli, EC coordinates, big certificate serial numbers), carried through the JSON::Any world krikri's engine boundary speaks. JSON::Any's raw union tops out at Int64, so a host cannot hand the engine a real wide integer directly: the host stores the value as this marked string instead, #from_json_any turns it into a BigIntValue (so templates, tests and comparisons see a real int), and #to_json_any turns a BigIntValue back into the marked string for the return trip. The private-use control character makes a false positive on real string data effectively impossible. krikri keeps a byte-identical constant in Krikri::BIGINT_SENTINEL_PREFIX for the plugin binaries, which link neither this shard nor the jinja engine and so cannot reference it here.
Dict keys are stored as strings; non-string Python keys get a marker prefix so repr/lookup/json can recover their true type and value.
The reserved words that are tokenized as idents but mean something to the parser.
Filters that accept keyword arguments in real Jinja2; map/filter passing must raise for any others (Python raises TypeError instead).
Strict positional arity for filters python raises on when over-called.
Class methods
Ansible's strict undefined: raises when an undefined value is USED, and chains through attribute/subscript access on the way there.
Truncating quotient/remainder with Python's floor adjustment.
Int64-overflowing decimal strings are the engine's big-int representation; Python reprs them unquoted.
Decimal-string big-int helpers shared by pow and add overflow paths. Decimal-string bignum: needed when Int64 pow overflows (Python has arbitrary-precision ints).
Exact comparison of a decimal-string integer against a Float64. Python's int/float comparison is exact arithmetic; converting the digits to Float64 instead both rounds and overflows past ~1.8e308 (an RSA modulus raises on the conversion outright). The float decomposes EXACTLY as mantissa * 2^exponent (Math.frexp is exact for IEEE doubles); both sides are scaled to plain integers by a power of two - computed by repeated doubling with the big-multiplication helper, since the exponent reaches +-1074 - and compared as decimal strings. Returns 0 for a NaN operand only because a total order cannot express Python's all-False NaN comparisons; equality checks NaN separately.
Exact comparison of a decimal-string integer against an Int64.
Unsigned long division of decimal strings; a and b must be non-negative.
Ordering: returns -1, 0, 1. Raises on incomparable types (Python-like).
Builds a boxed context hash from plain Crystal values.
Builds an engine that inherits the shared default engine's registered
filters, tests, and globals, with the caller's loader, lexer options, and
undefined behavior. Use this instead of Engine.new when host extensions
must stay visible (for example a .j2 render with its own loader).
Alternate encoding for python's 1 == True key equivalence, or nil.
Plain string form of a numeric key, or nil for anything else. Hosts
that hand the engine pre-built dicts through a JSON round trip lose
their YAML key types (a JSON object's keys are always strings), so
an integer YAML key (7:) arrives as the plain string "7" while the
subscript still indexes with the real int - the type-preserving
encodings above miss it and the lookup wrongly reports undefined
(robertdebock.tomcat's _tomcat_unarchive_urls[instance.version]
became the literal string "undefined" instead of a download URL).
Real Jinja2 matches dict keys by value, so the plain form is tried
as a last resort. Strings deliberately get no fallback here: the
caller has already tried the string itself, and coercing a string
key into a numeric encoding would fabricate matches real Jinja2
does not make.
The integral-truncation form of a numeric key ("8" for 8.0) - the int/float key-equivalence fallback dict_lookup tries after the plain string form (Python: d[8] also hits a float 8.0 key, d[8.0] hits an int 8 key).
One dict lookup for every call site: the type-preserving encoding, then the True/1 equivalence alternate, then the plain string form, then the integral-truncation form.
Like evaluate_expression, but reports undefined results explicitly so
callers can tell them apart from a JSON null value.
python str.istitle: each cased word starts upper, continues lower
Percent-encoding matching urllib.parse.quote (space becomes %20).
Python %-style formatting (the format filter). tuple_arg marks a
parenthesized right operand; CPython only errors on leftover args for
tuples and scalars, never for lists/dicts/undefined.
CPython str repr: single quotes preferred, double when the value contains ' but not ", backslash/quote/control chars escaped.
Percent-encoding matching urllib.parse.quote_plus (space becomes +).
str.format: positional ({} and {N}) replacement with {{ }} escapes.
Converts a JSON::Any value into a boxed template value.
Python's type name for a value, as error messages report it.
The message real Jinja2/Ansible reports names the variable that was missing; fall back to a generic word when the name is unknown.
Python-like equality/comparison across values.
Deep-converts plain Crystal values (nested hashes/arrays of mixed types) into boxed template values.
Nested types
- KrikriJinja::AnyV
- KrikriJinja::AnyValue
- KrikriJinja::BigIntValue
- KrikriJinja::Callable
- KrikriJinja::CallerCallable
- KrikriJinja::Context
- KrikriJinja::Cycler
- KrikriJinja::DictLoader
- KrikriJinja::Engine
- KrikriJinja::ErrorKind
- KrikriJinja::Evaluator
- KrikriJinja::ExprNode
- KrikriJinja::ExpressionResult
- KrikriJinja::FileSystemLoader
- KrikriJinja::FilterFn
- KrikriJinja::FunctionFn
- KrikriJinja::GeneratorValue
- KrikriJinja::HostContext
- KrikriJinja::HostObject
- KrikriJinja::Joiner
- KrikriJinja::JsonFilterFn
- KrikriJinja::JsonFunctionFn
- KrikriJinja::JsonTestFn
- KrikriJinja::Lexer
- KrikriJinja::LexerOptions
- KrikriJinja::Loader
- KrikriJinja::LoopCallable
- KrikriJinja::LoopObject
- KrikriJinja::MacroCallable
- KrikriJinja::Markup
- KrikriJinja::Namespace
- KrikriJinja::Node
- KrikriJinja::Nodes
- KrikriJinja::Parser
- KrikriJinja::PythonRandom
- KrikriJinja::SimpleCallable
- KrikriJinja::StrictUndefined
- KrikriJinja::TargetSpec
- KrikriJinja::TemplateError
- KrikriJinja::TestFn
- KrikriJinja::Token
- KrikriJinja::TokenType
- KrikriJinja::TupleValue
- KrikriJinja::Undefined
- KrikriJinja::VariableResolver