dinja 1.1.0
dinja: ^1.1.0 copied to clipboard
A minimal, zero-dependency Jinja templating engine for Dart, ported from llama.cpp. Focused on security and efficiency.
1.1.0 #
- Added
package:dinja/ast.dartfor template analysis without importingsrc/:parseTemplate, which parses a template into aProgram; the AST node types; andLexerExceptionandParserException.package:dinja/dinja.dartis unchanged. - Fixed string equality to compare content only:
''.strip() == ''is now true, andsafeor input-marked strings equal plain ones. - Removed a debug
printto stdout when aforloop iterates a function; the error now names the function. - Fixed tests with one unparenthesized argument, such as
1 is eq 1and'a' is in ['a'], which failed to parse. As in Jinja2, a value after a test without a comma is now its argument:[x is odd 1]means[x is odd(1)]. - Fixed
uniqueto compare items with Python equality:[1, '1']keeps both,[1, 1.0, true]keeps one. It now ignores string case by default, as Jinja2 does. - Fixed a
ParserExceptionat the end of the template reporting position-1; it now reports the end of the template. - Fixed an incomplete expression at the end of the template, such as
{{ 1 +, throwingRangeErrorinstead ofParserException. - Fixed
ParserExceptionfromTemplateon templates with\r\nor a trailing newline: itssource,pos,lineandcolnow all refer to the normalized text, as withparseTemplate. - Changed
uniqueto follow Jinja2's signature,unique(case_sensitive=false, attribute=none): the first positional argument is nowcase_sensitive, notattribute.uniquenow also deduplicates the characters of a string and the keys of a dict. - Fixed input marking being dropped by
~, string repetition (*),replace,capitalize,title,string,indentand the last piece ofsplit(first ofrsplit), matching llama.cpp. Input-marked text from these is now escaped on output like{{ value }}.joinstill drops the marking, as in llama.cpp. - Fixed double escaping when an escaped block, such as a
{% set %}block or macro output, is joined with+to plain text.
1.0.0 #
- Initial release of Dinja.
- Minimal Jinja2 implementation ported from llama.cpp.
- Support for LLM chat templates.
- Secure input marking system.
- Fixed unused declaration in
nodes.dart. - Fixed
not inoperator logic for Maps. - Fixed duplicate key in
builtins.dart. - Added cross-compatibility generation script (
script/generate_cross_test.py).