-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a basic example and a keywords file
- Loading branch information
1 parent
85ee026
commit 6ffd721
Showing
2 changed files
with
34 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#include <ministache.hpp> | ||
|
||
/*************************************************** | ||
This is a very basic example for the ministache library | ||
(https://github.com/floatplane/ministache). | ||
It shows how the library can be used to render a Mustache template with a JSON object. | ||
For more details on Mustache syntax, see http://mustache.github.io/mustache.5.html | ||
****************************************************/ | ||
|
||
void setup() { | ||
Serial.begin(9600); | ||
|
||
// Create a JSON object to hold the data that we'll use in our template | ||
JsonDocument data; | ||
data["name"] = "World"; | ||
data["value"] = 42; | ||
|
||
// Create a template string | ||
String templateString = "Hello, {{name}}! The answer is {{value}}."; | ||
|
||
// Render the template with the data | ||
String output = ministache::render(templateString, data); | ||
|
||
// Print the result | ||
Serial.println(output); // Prints: Hello, World! The answer is 42. | ||
} | ||
|
||
void loop() { | ||
delay(500); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
ministache KEYWORD1 | ||
render KEYWORD2 |