Skip to content

Commit

Permalink
Cleanup README, rename header and source file
Browse files Browse the repository at this point in the history
  • Loading branch information
floatplane committed Mar 16, 2024
1 parent 1f6a70f commit 7038eca
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 8 deletions.
15 changes: 13 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
[![.github/workflows/arduino_lint.yml](https://github.com/floatplane/ministache/actions/workflows/arduino_lint.yml/badge.svg)](https://github.com/floatplane/ministache/actions/workflows/arduino_lint.yml)
[![.github/workflows/build.yml](https://github.com/floatplane/ministache/actions/workflows/build.yml/badge.svg)](https://github.com/floatplane/ministache/actions/workflows/build.yml)
[![.github/workflows/test.yml](https://github.com/floatplane/ministache/actions/workflows/test.yml/badge.svg)](https://github.com/floatplane/ministache/actions/workflows/test.yml)
[![.github/workflows/static_analysis.yml](https://github.com/floatplane/ministache/actions/workflows/static_analysis.yml/badge.svg)](https://github.com/floatplane/ministache/actions/workflows/static_analysis.yml)
[![.github/workflows/clangformat.yml](https://github.com/floatplane/ministache/actions/workflows/clangformat.yml/badge.svg)](https://github.com/floatplane/ministache/actions/workflows/clangformat.yml)

# Ministache

A spec-complete implementation of the [Mustache](https://mustache.github.io/) templating language for Arduino.
A spec-complete implementation of the [Mustache](https://mustache.github.io/) templating language for Arduino. A sane alternative to building up complex strings via concatenation and custom code. Very useful for embedded web servers!

## Features

Expand All @@ -20,11 +21,21 @@ Complete support for all elements of the [Mustache core specification](https://g

See the [mustache documentation](https://mustache.github.io/mustache.5.html) for more details on these features.

## Example
## Basics

```c++
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](examples/basic/basic.ino) for a sketch demonstrating basic Ministache usage.

## Partials

Partials are a powerful Mustache feature allow you to define a chunk of template code and use it in a loop. See [partials.ino](examples/partials/partials.ino) for a sketch demonstrating how to use partials with Ministache.

## Projects using Ministache

- [floatplane/mitsubishi2MQTT](https://github.com/floatplane/mitsubishi2MQTT)
2 changes: 1 addition & 1 deletion examples/basic/basic.ino
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include <ministache.hpp>
#include <Ministache.h>

/***************************************************
This is a very basic example for the ministache library
Expand Down
5 changes: 3 additions & 2 deletions examples/partials/partials.ino
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include <ministache.hpp>
#include <Ministache.h>

/***************************************************
This is a very basic example for the ministache library
Expand Down Expand Up @@ -40,7 +40,8 @@ void setup() {
String reportString = "People report:\n{{#people}}{{> person}}{{/people}}";

// Render the template with the data. The third argument is the partials list. This
// defines how to map a partial reference like {{>person }} to a particular template (personString).
// defines how to map a partial reference like {{>person }} to a particular template
// (personString).
String output = ministache::render(reportString, data, {{"person", personString}});

// Print the result
Expand Down
2 changes: 1 addition & 1 deletion library.properties
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ paragraph=Ministache is a small, fast and complete implementation of the Mustach
category=Data Processing
url=https://github.com/floatplane/ministache
architectures=*
includes=ministache.hpp
includes=Ministache.h
depends=ArduinoJson (>=7.0.0)

2 changes: 1 addition & 1 deletion src/ministache.cpp → src/Ministache.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

#include "ministache.hpp"
#include "Ministache.h"

#include <Arduino.h>
#include <ArduinoJson.h>
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion test/ministache.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#define DOCTEST_CONFIG_IMPLEMENT // REQUIRED: Enable custom main()

#include "ministache.hpp"
#include "Ministache.h"

#include <Arduino.h>
#include <ArduinoJson.h>
Expand Down

0 comments on commit 7038eca

Please sign in to comment.