ykmnkmi / jinja.dart

Jinja2 template engine port for Dart.
https://pub.dev/packages/jinja
MIT License
51 stars 11 forks source link
dart2 dartlang jinja2 template template-engine

jinja

Pub Package Test Status CodeCov

Jinja (3.x) server-side template engine port for Dart 2. Variables, expressions, control structures and template inheritance.

Version 0.6.0 introduces breaking changes

For more information, see CHANGELOG.md.

Documentation

It is mostly similar to Jinja templates documentation, differences provided below.

work in progress.

Differences with Python version

Dynamically invoked members (can increase the size of the JS output)

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:

Done:

Note: item - not supported

Contributing

Contributions are welcome! Please open an issue or pull request on GitHub. Look at the ToDo list and comments in the code for ideas on what to work on. There are no strict rules, but please try to follow the existing code style.

As non-native English speaker and learner, I will be grateful for any corrections in the documentation and code comments.

Support

Post issues and feature requests on the GitHub issue tracker.