template_engine
2.0.3, released 10 days ago by an unverified publisher
Dart library to parse and render text templates with variables and custom tags.
What it does
TemplateEngine parses template text into a parse tree and renders it to various outputs such as HTML, Markdown, JSON, YAML, XML, or custom code. It supports statements, expressions, loops, conditionals, and custom grammar extensions.
AI-written summary of version 2.0.3, based on the package's README and metadata. Report an inaccuracy
Use it when
- Generating static HTML or Markdown from templates
- Producing configuration files (JSON/YAML) from templates
- Creating code snippets or scripts via templating
- Automating report generation with variable data
Skip it when
- Building UI widgets that require reactive updates
- Replacing a full templating engine with a simple string interpolation
- Using it for large-scale data processing where performance is critical
Strengths
- Highly customizable grammar and tags
- Supports multiple output formats out of the box
- No external code generation required
- Simple API for parsing and rendering
Weaknesses
- Not designed for UI rendering
- No built-in caching or performance optimizations
- Limited documentation beyond the README
Setup
- Kind
- Pure Dart
- Effort
- Low
- Code generation
- No
- Direct dependencies
- 7
import 'package:template_engine/template_engine.dart';
final engine = TemplateEngine();
final parseResult = await engine.parseText('Hello {{name}}.');
final renderResult = await engine.render(parseResult, variables: {'name': 'world'});
print(renderResult.text);Alternatives
Packages that do the same job and could replace template_engine.
- liquify
A powerful and extensible Liquid template engine for Dart.
72Compare - jinja
Jinja2 template engine port for Dart supporting variables, control structures, and template inheritance.
84Compare - baseflow_plugin_template
A template for plugin examples
53Compare - barbecue
Render text tables for CLI-based Dart applications with custom borders, padding, and ANSI colors.
50Compare
Works with
Packages commonly used together with template_engine: ones it builds on, ones built on it, and its own family.
- yamltemplate_engine depends on itA Dart library for parsing YAML documents into Dart data structures.
- cryptotemplate_engine depends on itProvides SHA, MD5, and HMAC hashing functions for Dart.
- xmltemplate_engine depends on itFull-featured XML and XPath library for DOM parsing, SAX streaming, and fluent building.
- recasetemplate_engine depends on itChanges the case of input text to various conventions.
- documentation_builderBuilt on template_engineGenerates documentation files from template files, importing other files or Dart documentation comments.