template_engine 1.5.2
template_engine: ^1.5.2 copied to clipboard
A Dart package to parse and render templates, using (nested) variables and custom tags.
The TemplateEngine can:
- Parse the Template text into a parser tree
- Render the parser tree to a output such as:
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:
- Read the wiki documentation
- See the examples
- Install the template_engine package in your project
- Start coding
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