Skip to content
pubscout

jinja

0.7.2, released 2 months ago by ykmnkmi.kz

Jinja2 template engine port for Dart supporting variables, control structures, and template inheritance.

WASM-ready
$ flutter pub add jinja
Source repository

What it does

Jinja provides a template engine for Dart that supports variables, expressions, control structures, and template inheritance. It lets you render templates from strings or files directly to strings or a StringSink.

AI-written summary of version 0.7.2, based on the package's README and metadata. Report an inaccuracy

Use it when

  • You need to render text templates with variables and logic in Dart
  • You want to use Jinja2-style template syntax in a Dart or Flutter project

Skip it when

  • You need automated HTML auto-escaping out of the box
  • You require full Python Jinja2 feature parity including *args and **kwargs

Strengths

  • Familiar Jinja2 syntax and template inheritance
  • Supports multiple loaders like FileSystemLoader and MapLoader

Weaknesses

  • Some Python Jinja features and auto-escaping are removed
  • String slices and negative indexes are not fully supported

Setup

Kind
Pure Dart
Effort
Low
Code generation
No
Direct dependencies
5

Not documented

var environment = Environment();
var template = environment.fromString('Hello {{ name }}!');
print(template.render({'name': 'World'}));

Alternatives

Packages that do the same job and could replace jinja.

Works with

Packages commonly used together with jinja: ones it builds on, ones built on it, and its own family.