template_expressions
4.4.1, released 6 weeks ago by ilt.run
A Dart library to process string-based templates using expressions.
What it does
It processes string-based templates using built-in or custom expressions. It supports various expression syntaxes such as hash, mustache, pipe, and standard Dart-like string interpolation, alongside many built-in context objects like Codex, Crypto, DateFormat, and FileSystem.
AI-written summary of version 4.4.1, based on the package's README and metadata. Report an inaccuracy
Use it when
- You need to parse and evaluate text templates with embedded Dart-like expressions.
- You want support for multiple template syntaxes like mustache or hash blocks.
Skip it when
- You are looking for full heavy-weight HTML templating engines with looping/conditional markup control flow.
- You need compile-time code generation for your templates.
Strengths
- Multiple syntax options (hash, mustache, pipe, standard).
- Rich set of built-in context objects and helpers including crypto, date formatting, and file systems.
Weaknesses
- Limited documentation on some advanced objects in the provided material.
- Requires proper escaping for certain standard interpolation syntaxes.
Setup
- Kind
- Pure Dart
- Effort
- Low
- Code generation
- No
- Direct dependencies
- 14
Add template_expressions to pubspec.yaml and run dart pub get.
final template = Template('##firstName.toUpperCase()##', syntax: [HashExpressionSyntax()]);
final result = template.apply({'firstName': 'John'});Alternatives
Packages that do the same job and could replace template_expressions.
- jinja
Jinja2 template engine port for Dart supporting variables, control structures, and template inheritance.
84Compare - validators2
String validation and sanitization for Dart.
83Compare - baseflow_plugin_template
A template for plugin examples
53Compare - math_parser
Parse and evaluate mathematical expressions in Dart.
52Compare
Works with
Packages commonly used together with template_expressions: ones it builds on, ones built on it, and its own family.
- cryptotemplate_expressions depends on itProvides SHA, MD5, and HMAC hashing functions for Dart.
- petitparsertemplate_expressions depends on itBuild fast, composable, and type-safe grammars and parsers in plain Dart code.
- intltemplate_expressions depends on itA Dart library for internationalization and localization, providing message translation, plural/gender handling, and date/number formatting.
- filetemplate_expressions depends on itPluggable, mockable file system abstraction for Dart with in-memory support.
- loggingtemplate_expressions depends on itProvides configurable logging with levels and stream listeners for Dart apps.
- converttemplate_expressions depends on itEncoders and decoders for converting between different data representations.
- fake_asynctemplate_expressions depends on itFake asynchronous events like timers and microtasks for deterministic testing.
- rxdarttemplate_expressions depends on itImplementation of the ReactiveX API for asynchronous programming leveraging native Dart Streams.