Skip to content

Commit

Permalink
Add a basic example and a keywords file
Browse files Browse the repository at this point in the history
  • Loading branch information
floatplane committed Mar 16, 2024
1 parent 85ee026 commit 6ffd721
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
32 changes: 32 additions & 0 deletions examples/basic/basic.ino
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);
}
2 changes: 2 additions & 0 deletions keywords.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
ministache KEYWORD1
render KEYWORD2

0 comments on commit 6ffd721

Please sign in to comment.