Skip to content

Spec-complete implementation of Mustache templates for Arduino

License

Notifications You must be signed in to change notification settings

floatplane/ministache

Repository files navigation

PlatformIO Registry .github/workflows/build.yml .github/workflows/test.yml .github/workflows/static_analysis.yml .github/workflows/clangformat.yml BuyMeACoffee

Ministache

A spec-complete implementation of the Mustache template language for Arduino. The best way to generate complex text content such as HTML, with full support for all Mustache features and 100% test coverage. A sane alternative to building up complex strings via concatenation and custom code. Very useful for embedded web servers!

Features

Complete support for all elements of the Mustache core specification version 1.4.1, with 100% of tests passing. Supported features:

  • Interpolation
  • Sections
  • Iteration
  • Partials
  • Comments
  • Custom delimiters

See the mustache documentation for more details on these features.

Basics

ArduinoJson::JsonDocument data;
data[F("subject")] = F("world");
const String output = ministache::render(F("Hello, {{subject}}!"), data);
Serial.println(output); // Hello, world!

See basic.ino for a sketch demonstrating basic Ministache usage.

Partials

Partials are a powerful Mustache feature, allowing you to define a chunk of template code and use it in a loop. See partials.ino for a sketch demonstrating how to use partials with Ministache.

Projects using Ministache

Support

I hope this is useful to you! If it is, then maybe you'd like to buy me a coffee? 😊

Buy Me A Coffee