dinja library

A Jinja engine for LLM chat templates, ported from llama.cpp's common/jinja.

Values wrapped in JinjaString.user are marked as input and escaped when rendered.

Classes

JinjaBoolean
JinjaFloat
JinjaFunction
JinjaInteger
JinjaList
JinjaLoopContext
JinjaMap
JinjaNone
JinjaString
A string wrapper that tracks the origin of its parts (user input vs template).
JinjaStringPart
Represents a part of a string, tracking whether it originated from user input.
JinjaStringValue
JinjaTuple
JinjaUndefined
JinjaValue
Base class for all runtime values under the Dinja type system.
Template
Represents a compiled Jinja template.

Functions

val(Object? v) → JinjaValue
Converts a Dart value to a JinjaValue.

Typedefs

JinjaFunctionHandler = JinjaValue Function(List<JinjaValue> args, Map<String, JinjaValue> kwargs)

Exceptions / Errors

ParserException
Exception thrown when a parsing error is encountered.