-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbuildinhelpers.cpp
More file actions
52 lines (45 loc) · 1.08 KB
/
buildinhelpers.cpp
File metadata and controls
52 lines (45 loc) · 1.08 KB
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
/*
* Copyright (C) Alex Nekipelov (alex@nekipelov.net)
* License: BSD
*/
#include <boost/algorithm/string/replace.hpp>
#include "buildinhelpers.h"
namespace cpptl {
Value include(TemplateEngine &engine, const Value &context, const Value &args)
{
if( args.size() > 0 )
{
const std::string &fileName = args[0].toString();
Template subTempl = engine.templFile(fileName);
return subTempl.render( context );
}
else
{
assert( false );
return Value();
}
}
Value rawHtml(const Value &, const Value &html)
{
if( html.size() == 1 )
{
if( html[0].type() == Value::String)
{
std::string s = html[0].toString();
boost::replace_all(s, "&", "&");
boost::replace_all(s, ">", ">");
boost::replace_all(s, "<", "<");
boost::replace_all(s, """, "\"");
return Value(s, Value::UnsafeStringTag());
}
else
{
return html[0];
}
}
else
{
return Value("");
}
}
} // namespace cpptl