liquid_engine 0.2.2 copy "liquid_engine: ^0.2.2" to clipboard
liquid_engine: ^0.2.2 copied to clipboard

A dart port of the liquid / django HTML template engine.

A dart port of the liquid / django template engine.

Created under a BSD-style license.

Usage #

A simple usage example:

import 'package:liquid_engine/liquid_engine.dart';

main() {
  final raw = '''
<html>
  <title>{{ title | default: 'Liquid Example'}}</title>
  <body>
    <table>
    {% for user in users %}
      <tr>
        <td>{{ user.name }}</td>
        <td>{{ user.email }}</td>
        <td>{{ user.roles | join: ', ' | default: 'none' }}</td>
      </tr>
    {% endfor %}
    </table>
  </body>
</html>
  ''';

  final context = Context.create();

  context.variables['users'] = [
    {
      'name': 'Standard User',
      'email': 'standard@test.com',
      'roles': [],
    },
    {
      'name': 'Admin Administrator',
      'email': 'admin@test.com',
      'roles': ['admin', 'super-admin'],
    },
  ];

  final template = Template.parse(context, Source.fromString(raw));
  print(await template.render(context));
}

Features and bugs #

Please file feature requests and bugs at the issue tracker.

19
likes
130
points
8.22k
downloads

Publisher

unverified uploader

Weekly Downloads

A dart port of the liquid / django HTML template engine.

Repository (GitHub)
View/report issues

Documentation

API reference

License

BSD-3-Clause (license)

Dependencies

string_scanner

More

Packages that depend on liquid_engine