aboutsummaryrefslogtreecommitdiffstats
path: root/template_test/mustachetest.cc
diff options
context:
space:
mode:
Diffstat (limited to 'template_test/mustachetest.cc')
-rw-r--r--template_test/mustachetest.cc26
1 files changed, 26 insertions, 0 deletions
diff --git a/template_test/mustachetest.cc b/template_test/mustachetest.cc
new file mode 100644
index 0000000..3b80b5d
--- /dev/null
+++ b/template_test/mustachetest.cc
@@ -0,0 +1,26 @@
+#include <iostream>
+#include <fstream>
+#include <string>
+#include <iterator>
+#include "../mustache.h"
+#include "../json.h"
+using namespace std;
+using namespace crow;
+using namespace crow::mustache;
+
+string read_all(const string& filename)
+{
+ ifstream is(filename);
+ string ret;
+ copy(istreambuf_iterator<char>(is), istreambuf_iterator<char>(), back_inserter(ret));
+ return ret;
+}
+
+int main()
+{
+ auto data = json::load(read_all("data"));
+ auto templ = compile(read_all("template"));
+ context ctx(data);
+ cout << templ.render(ctx);
+ return 0;
+}