diff --git a/README.md b/README.md index 351b337..9b1555e 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,4 @@ +[![.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) @@ -5,7 +6,7 @@ # 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 @@ -20,7 +21,7 @@ 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; @@ -28,3 +29,13 @@ 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) \ No newline at end of file diff --git a/examples/basic/basic.ino b/examples/basic/basic.ino index a4e3568..5d103bd 100644 --- a/examples/basic/basic.ino +++ b/examples/basic/basic.ino @@ -1,4 +1,4 @@ -#include +#include /*************************************************** This is a very basic example for the ministache library diff --git a/examples/partials/partials.ino b/examples/partials/partials.ino index 31f6d95..e88848d 100644 --- a/examples/partials/partials.ino +++ b/examples/partials/partials.ino @@ -1,4 +1,4 @@ -#include +#include /*************************************************** This is a very basic example for the ministache library @@ -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 diff --git a/library.properties b/library.properties index 01a3463..97b36ce 100644 --- a/library.properties +++ b/library.properties @@ -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) diff --git a/src/ministache.cpp b/src/Ministache.cpp similarity index 99% rename from src/ministache.cpp rename to src/Ministache.cpp index caae55b..49ae0cd 100644 --- a/src/ministache.cpp +++ b/src/Ministache.cpp @@ -1,5 +1,5 @@ -#include "ministache.hpp" +#include "Ministache.h" #include #include diff --git a/src/ministache.hpp b/src/Ministache.h similarity index 100% rename from src/ministache.hpp rename to src/Ministache.h diff --git a/test/ministache.cpp b/test/ministache.cpp index 0b3909c..43d3bdf 100644 --- a/test/ministache.cpp +++ b/test/ministache.cpp @@ -1,6 +1,6 @@ #define DOCTEST_CONFIG_IMPLEMENT // REQUIRED: Enable custom main() -#include "ministache.hpp" +#include "Ministache.h" #include #include