template_engine 1.5.3

SDKdartflutter
Platformandroidioswindowslinuxmacos

A Dart package to parse and render templates, using (nested) variables and custom tags.

Pub Package Project on github.com Project Wiki pages on github.com Pub Scores Stars ranking on github.com Open issues on github.com Open pull requests on github.com Project License

The TemplateEngine can:

Features

  • Template expressions that can contain (combinations of):
    • Data types
    • Constants
    • Variables
    • Operators
    • Functions e.g. functions to import:
      • Pure files (to be imported as is)
      • Template files (to be parsed and rendered)
      • XML files (to be used as a data source)
      • JSON files (to be used as a data source)
      • YAML files (to be used as a data source)
  • All of the above can be customized or you could add your own.

Getting Started

To get started:

Usage

A typical way to use the template_engine:

test/src/template_engine_template_example_test.dart

import 'package:shouldly/shouldly.dart';
import 'package:template_engine/template_engine.dart';
import 'package:test/test.dart';

Future<void> main() async {
  test('example should work', () async {
    var engine = TemplateEngine();
    var parseResult = await engine.parseText('Hello {{name}}.');
    var renderResult = await engine.render(parseResult, {'name': 'world'});
    renderResult.text.should.be('Hello world.');
  });
}

For more see: Examples

Documentation

For more information read the template_engine wiki