From 2e8f9f383d3ebc78fb2cb8ad37ad855ac28d11dd Mon Sep 17 00:00:00 2001 From: ipknHama Date: Thu, 31 Jul 2014 00:50:38 +0900 Subject: begin implementation: mustache based template engine --- template_test/mustachetest.cc | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 template_test/mustachetest.cc (limited to 'template_test/mustachetest.cc') 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 +#include +#include +#include +#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(is), istreambuf_iterator(), 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; +} -- cgit v1.2.3-54-g00ecf