Skip to content

ergonlabs/liquid_dart

Repository files navigation

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': '[email protected]',
      'roles': [],
    },
    {
      'name': 'Admin Administrator',
      'email': '[email protected]',
      '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.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages