Menu

[r183]: / templates / trunk / test.cpp  Maximize  Restore  History

Download this file

56 lines (42 with data), 777 Bytes

 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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#include <iostream>
#include "content.h"
#include "renderer.h"
#include <boost/format.hpp>
using namespace std;
using namespace tmpl;
bool counter(content &c,int &i)
{
if(i<5) {
string tmp=(boost::format("%d") % i).str();
c["val"]=tmp;
i++;
return true;
}
else {
i=0;
return false;
}
}
int main()
{
try{
content c;
template_data tmpl("test.opcode");
renderer r(tmpl);
string out;
c["istrue"]=true;
c["isfalse"]=false;
c["myref"]=string("foo_ref");
int i=0;
content::vector_t &l1=c.vector("list_1",1);
l1[0]["val"]=string("One item");
c.list("list_empty");
c.signal("count",boost::bind(counter,_1,i));
r.render(c,"main",out);
cout<<out<<endl;
}
catch(std::exception &e){
std::cout<<e.what()<<'\n';
}
return 0;
}
MongoDB Logo MongoDB