mustache_template
2.0.6, released 2 months ago by flutter.dev
A Dart library that parses and renders Mustache templates.
What it does
It parses Mustache template strings into Template objects and can render them with provided data maps. Supports strict and lenient modes, partials, lambdas, and HTML escaping control.
AI-written summary of version 2.0.6, based on the package's README and metadata. Report an inaccuracy
Use it when
- You need server‑side or client‑side text generation using the Mustache syntax.
- You want a pure‑Dart solution without external dependencies.
Skip it when
- You require a full UI widget library or state‑management solution.
- You need a template engine with built‑in HTML sanitization beyond simple escaping.
Strengths
- Zero external dependencies and pure Dart implementation.
- Supports Mustache spec, partials, lambdas, and both strict and lenient modes.
Weaknesses
- Only handles text templating; no integration with UI frameworks.
- Limited to Mustache features; no advanced templating extensions.
Setup
- Kind
- Pure Dart
- Effort
- Low
- Code generation
- No
- Direct dependencies
- 0
const source = '''
{{# names }}
<div>{{ lastname }}, {{ firstname }}</div>
{{/ names }}
{{^ names }}
<div>No names.</div>
{{/ names }}
{{! I am a comment. }}
''';
final template = Template(source, name: 'example');
final output = template.renderString({
'names': [
{'firstname': 'Greg', 'lastname': 'Lowe'},
{'firstname': 'Bob', 'lastname': 'Johnson'},
],
});Alternatives
Packages that do the same job and could replace mustache_template.
- liquify
A powerful and extensible Liquid template engine for Dart.
72Compare - baseflow_plugin_template
A template for plugin examples
53Compare - simple_mustache
Dart implementation of a mustache subset for simple String templates with filters.
47Compare - mustachex
Extended Mustache template processor for Dart with variable recasing and missing variable handling.
41Compare
Works with
Packages commonly used together with mustache_template: ones it builds on, ones built on it, and its own family.
- melosBuilt on mustache_templateA tool for managing Dart and Flutter monorepos with script execution, versioning, and publishing.
- masonBuilt on mustache_templateDart template generator for quick file creation
- flutter_app_packagerBuilt on mustache_templatePackage Flutter apps into native installers and archives for desktop platforms.
- jaspr_contentBuilt on mustache_templateJaspr plugin for building content-driven sites like documentation and blogs.
- tabler_icons_nextBuilt on mustache_templateFlutter icon package for Tabler Icons with regular updates from upstream.
- dart_defineBuilt on mustache_templateUtility for generating and populating dart-define configuration files