aboutsummaryrefslogtreecommitdiffstats
path: root/template_test/mustachetest.cc
blob: 3b80b5d74b3235272419e9e8f57f9039b0a5c316 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
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;
}