Skip to content
pubscout

mustachex

1.0.0, released 3 years ago by an unverified publisher

Extended Mustache template processor for Dart with variable recasing and missing variable handling.

WASM-ready
$ flutter pub add mustachex
Source repository

What it does

Processes Mustache templates with added support for variable recasing, missing variable fulfillment functions, and automatic hasFoo guards. It ports and extends previous mustache and mustache_template packages.

AI-written summary of version 1.0.0, based on the package's README and metadata. Report an inaccuracy

Use it when

  • You need to render text templates using Mustache syntax in Dart or Flutter.
  • You need automatic variable recasing such as snake_case or pascalCase inside templates.
  • You need custom fallback handlers for missing variables during template rendering.

Skip it when

  • You require complex logic processing that goes beyond template string replacement.
  • You are already heavily invested in alternative parsing libraries like xml or yaml.

Strengths

  • Supports multiple variable recasing formats out of the box.
  • Provides missing variable fulfillment callbacks.
  • Includes helpful hasFoo guard checks for various types of values.

Weaknesses

  • Depends on a fork of older unmaintained packages ported into the repository.
  • Limited to template processing use cases.

Setup

Kind
Pure Dart
Effort
Low
Code generation
No
Direct dependencies
5
import 'package:mustachex/mustachex.dart';

main() async {
  var template = '{{greeting_pascalCase}} {{world_pc}}!';
  var vars = {'greeting': 'HELLO'};
  String fulfillmentFunction(MissingVariableException variable) {
    return 'WORLD';
  }
  var processor = MustachexProcessor(
      initialVariables: vars, missingVarFulfiller: fulfillmentFunction);
  var rendered = await processor.process(template);
}

Alternatives

Packages that do the same job and could replace mustachex.

Works with

Packages commonly used together with mustachex: ones it builds on, ones built on it, and its own family.