Repository navigation
Update Rust crate minijinja to v3 - #59
Merged
Merged
Conversation
Enable the optional serde feature and wrap TOML variables in `Serde`. MiniJinja 3 removed `Value::from_serialize`.
Contributor
Author
Edited/Blocked NotificationRenovate will not automatically rebase this PR, because it does not recognize the last commit author and assumes somebody else may have edited the PR. You can manually request rebase by checking the rebase/retry box above. |
knu
approved these changes
Oct 9, 2026
Contributor
Merge Queue Status
This pull request spent 13 minutes 35 seconds in the queue, including 1 minute 10 seconds running CI. Required conditions to merge
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR contains the following updates:
2→3Release Notes
mitsuhiko/minijinja (minijinja)
v3.0.0Compare Source
MiniJinja 3 is a major release. It aligns template behavior and the value
model more closely with Jinja2, makes Serde optional, makes mutable
Statethecanonical way to call back into the engine, adds built-in automatic reloading
of templates, reworks the JavaScript bindings and makes the Python bindings
considerably faster. Errors involving undefined values and the debug info
shown for errors were improved as well.
Most projects will need some changes when upgrading. See
UPDATING.mdformigration instructions. The changes below are relative to 2.24.0 and include
everything from the 3.0.0 alpha releases.
Breaking Changes
serdeoptional, explicit and disabled by default. The rendering APIs,context!andargs!now consume values and convert exclusively throughInto<Value>. Serde conversion is requested with the newvalue::Serdewrapper which also replacesViaDeserializefor deserializing function arguments.Value::from_serializewas removed. Thedeserializationfeature was removed and is now part of theserdefeature. Disabling the feature fully removes the dependency. #528jsonfeature no longer depends onserdeandserde_json. Thetojsonfilter and JSON auto escaping now use a built-in JSON serializer. Invalid values now fail the serialization rather than being emitted asnull. Floats are formatted like recent versions ofserde_jsondo (for instance1e+16instead of1e16). Thespeedupsfeature now useszmijanditoato format numbers in JSON; the output is the same without it.Statethe canonical path for functions, filters, tests, objects, methods, formatters, unknown method callbacks and nested macro calls. Read-only typed callbacks can continue to use&State; state mutation and dynamic calls now require&mut State. Added typed render-local extensions that persist through includes, blocks and macros.State::get_or_set_temp_objectwas removed in favor of these extensions.Template::render_and_return_state,Template::render_to_write,Template::eval_to_state, theFilter,Test,TestResultandViaDeserializealiases,value::internand the no-opkey_interningfeature. The no-oploaderfeature was also removed; loader APIs remain available unconditionally.format_filterandFormatStylefrom the crate root into the newformattingmodule and renamedformat_filtertoformatting::format.trim_blocks,lstrip_blocksandkeep_trailing_newlinesettings fromEnvironmentintoSyntaxConfig. AddedSyntaxConfig::to_builderto modify an existing configuration. Template introspection viaTemplate::undeclared_variablesnow honors the whitespace settings.WhitespaceConfigwas removed from theunstable_machineryAPIs. #470custom_syntaxfeature. Custom delimiters, line statements and line comments are now always available. Theaho-corasickdependency was removed; start markers are now found with a simple scan which is as fast or faster and makes building a customSyntaxConfigabout 100 times faster.ErrorKind::InvalidDelimiter.AutoEscape::Customto hold aCow<'static, str>so custom auto escape formats can be determined at runtime.AutoEscapeis no longerCopyandState::auto_escapenow returns a reference.Valuefunction arguments to reject implicit keyword-argument values. Variadic functions that intentionally capture them can useValueOrKwargs. #596Value::from_pairs. Collecting pairs directly intoValuenow creates a sequence of tuples rather than a map.list,joinorsort, theinoperator and serialization processed them like other items. The newValueIter::checkedhelper provides the same behavior for custom code.Environment::set_loaderis now generic over the returned source, which can be aStringor aTemplateSource. Closures that relied on type inference through.into()or only returnOk(None)need an explicit type.minijinja-autoreloadcrate in favor of built-in automatic reloading (see below).Template Behavior
These changes apply to Rust and Go and therefore also to the Python and
JavaScript bindings.
tojsonto use Jinja2-compatible separator spacing. #785roundfilter to use round-half-even semantics and fixed decimal rounding edge cases. #948sequencetest to classify undefined values as sequences. #951upperandlowertests to reject non-strings and handle titlecase characters correctly. #952titlefilter treating every ASCII punctuation character as a word boundary. Words now start after whitespace or one of-,(,{,[and<as in Jinja2, so"don't"|titlerenders asDon'tinstead ofDon'T. #930-foo.barnow negatesfoo.barrather than looking upbaron-foo.formatfilter accepting undefined values with strict and semi-strict undefined behavior.andandorexpressions returning booleans instead of preserving their operands. #945<%and<%%=) sometimes picking the wrong marker.Features and Improvements
TemplateSourcewith an up-to-date check in addition to a plainString, and the environment re-invokes the loader when a template is looked up that is no longer up to date.path_loaderattaches a check based on the file's modification time and size. Auto reloading is enabled by default and can be disabled withEnvironment::set_auto_reload. Templates are reloaded through a shared reference so the environment no longer needs to be recreated or guarded by a lock. Thememo-mapdependency was removed. #819`user.name` is undefined), including where it came from if that was elsewhere. This adds no memory overhead to values. #871withblock or a filtered loop ({% for x in seq if cond %}) are no longer omitted when the error happens within or after it, and errors within macros no longer show variables from outside of the macro. Variables only referenced within the bodies of declared macros are no longer shown.minijinjaby about 14% in a default release build. Sorting by attribute andgroupbyare roughly twice as fast.Go
/v2to/v3.Environment.SetUnknownMethodCallback. #934loop.changed()always reporting a change. #936Python Bindings
extension-modulefeature. Building now requires maturin 1.9.4 or later.f64conversion. #944pass_statenot working on methods invoked from templates.JavaScript Bindings
The JavaScript bindings were largely rewritten:
causeis the original exception.undefinedBehavior.semi_strictundefined behavior (wassemi_strct).Map,Set,Date,BigInt,Uint8Arrayand typed arrays are supported, and class instances are accessed lazily with methods called on the instance. Cyclic structures fail with an error instead of overflowing the stack.Maps, none is returned asnulland integers outside of the safe range asBigInt. Functions and objects passed in are returned unchanged.SafeStringfor strings that should not be auto escaped. Callbacks receive safe strings asSafeStringand can return them to bypass auto escaping.TemplateErrorwithkind,detail,templateName,line,rangeandtemplateSourceproperties.addFunction,removeFilter,removeTest,setAutoEscapeCallback,setFinalizer,undeclaredVariablesInTemplateandundeclaredVariablesInStras well as thesyntaxproperty for custom delimiters and line statements and thepycompatproperty.Context,SyntaxConfig,AutoEscapeandUndefinedBehaviorare exported.passStatereceive aStateobject to look up variables, inspect the template name and auto escape mode, and apply filters and tests. Callbacks can throwTemplateErrorto fail with a specific error kind.datetimeformat,dateformat,timeformatandnow()) inminijinja-js/datetimewhich use the native time zone support of the JavaScript runtime.randcontrib feature (random,randrangeandlipsum) seeded fromMath.random.urlencode,loop_controlsandunicodefeatures as well as thehtml_entitiesandwordwrapcontrib features to match the Python bindings.renderStr,renderTemplate,renderNamedStrandevalExpris now optional.exportsmap. Node.js loads the wasm module synchronously (and supportsrequire()on versions withrequire(esm)), browsers, bundlers, Deno and Bun load it with top-level await. Theminijinja-js/initentry point allows initializing the module manually. Thedist/node,dist/webanddist/bundlerpaths are gone. The package is now about a quarter of its previous size.fragileandserde-wasm-bindgendependencies and updatedwasm-bindgento 0.2.129.Contrib
time/time-tzto Jiff. Custom formats now usestrftime-style syntax instead oftimeformat descriptions. With thetimezonefeature, time zones are looked up through the system time zone database when available. Thedatetimefeature no longer depends onserde. #694minijinja_contrib::rand::set_seed_sourceto provide seeds for the random functions on platforms without a source of randomness.CLI
undefinedfor expressions that evaluate to undefined.clap,rustylineand theserdebased data format crates were replaced byargument,minilineanddeser. Fig completions are no longer supported. The minimum supported Rust version of the CLI is now 1.88.Configuration
📅 Schedule: (in timezone Asia/Tokyo)
🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.
♻ Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.
🔕 Ignore: Close this PR and you won't be reminded about this update again.
This PR was generated by Mend Renovate. View the repository job log.