jinja 0.4.0
jinja: ^0.4.0 copied to clipboard
Jinja2 template engine for Dart. Variables, expressions, control structures and template inheritance.
jinja #
Jinja server-side template engine port for Dart 2. Variables, expressions, control structures and template inheritance.
0.4.0 version is breaking #
See CHANGELOG.md.
Documentation #
Mostly same as Jinja template documentation. work in progress.
Differences with Python version #
BigIntand complex numbers are not supported.- The
defaultfilter compares values withnull, nobooleanparameter. - The
definedandundefinedtests compares values withnull. - The
mapfilter compares values withnull. Useattributefor fields anditemfor items. Nested attributes and items are not supported. - If
Environment({getAttribute})is not passed,getItemwill be used. This allows you to use{{ map.key }}as{{ map['key'] }}expression. - work in progress
Dynamically invoked members #
[],+,-,*,/,~/,%operatorsobject.lengthgetterobject.callgetter- work in progress
- also
Function.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
- List of Control Structures
- Macros
- Call
- Import
- Loaders
- PackageLoader (VM)
- ...
- Extensions
- i18n
- Expression Statement
- Loop Controls
- Debug Statement
- Template compiler
- ...
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
- Automatic
- List of Control Structures
- For
- If
- Filters
- Assignments
- Block Assignments
- Extends
- Blocks
- Include
- Import Context Behavior
- 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
Contributing #
If you found a bug, typo or you have better description or comment for documentation, just create a new issue or even better fork and issue a pull request with your fix.