jinja 0.5.0-dev.25
jinja: ^0.5.0-dev.25 copied to clipboard
Jinja2 template engine for Dart. Variables, expressions, control structures and template inheritance.
jinja #
Jinja (3.x) server-side template engine port for Dart 2. Variables, expressions, control structures and template inheritance.
Version 0.4.0 introduces breaking changes #
See CHANGELOG.md.
Documentation #
It is mostly similar to Jinja templates documentation, differences provided below. work in progress.
Differences with Python version #
BigIntand complex numbers are not supported.- The
defaultfilter compares values withnull; there is nobooleanparameter. - The
definedandundefinedtests compare values withnull. - The
mapfilter also compares values withnull. Useattributeforobject.attributeanditemforobject[item]expressions. - Not yet supported:
- Slices and negative indexes
- Conditional and variable
extendsstatement variants - Choice, ignore missing and variable
includestatement variants
- If
Environment({getAttribute})is not passed, thegetItemmethod will be used. This allows you to use{{ map.key }}as an expression equivalent to{{ map['key'] }}. - work in progress
Dynamically invoked members #
[],+,-,*,/,~/,%operatorsobject.lengthgetterobject.callgetterFunction.apply(function, ...)
Example #
import 'package:jinja/jinja.dart';
// ...
var environment = Environment(blockStart: '...', blockEnd: '...');
var template = environment.fromString('...source...');
print(template.render({'key': value}));
// or write directly to StringSink (IOSink, HttpResponse, ...)
template.renderTo(stringSink, {'key': value});
See also examples with conduit and reflectable.
Status: #
TODO: #
- Environment
- constructor
- extensions
- selectAutoescape
- addExtension
- compileExpression
- policies
- constructor
- Template:
- generate
- stream
awaitsupport
- HTML Escaping
- Automatic
- List of Control Structures
- Macros 🔥
- Call 🔥
- Import
- Loaders
- PackageLoader (VM)
- ...
- Extensions
- i18n
- Expression Statement
- Loop Controls
- Debug Statement
- Template compiler (builder)
- ...
Done: #
- Variables
- Filters
- Tests
- Comments
- Whitespace Control
- Escaping
- Line Statements
- Comments
- Blocks
- Template Inheritance
- Base Template
- Child Template
- Super Blocks
- Nesting extends
- Named Block End-Tags
- Block Nesting and Scope
- HTML Escaping
- Manual
- List of Control Structures
- For
- If
- Filters
- Assignments
- Block Assignments
- Extends
- Blocks
- Include
- Import Context Behavior
- Include
- Expressions with filters (not all) and tests
- List of Global Functions
- list
- namespace
- range
- Loaders
- FileSystemLoader
- MapLoader (DictLoader)
- Extensions
- Do Statement
- With Statement
- Autoescape Overrides
Support #
Post issues and feature requests on the GitHub issue tracker.