overridable escape function

This commit is contained in:
Daniel Sipka 2016-02-01 20:41:33 +01:00
parent 0f1a7056c1
commit 57196d08c5
3 changed files with 10 additions and 0 deletions

View file

@ -10,6 +10,10 @@
namespace mstch {
struct config {
static std::function<std::string(const std::string&)> escape;
};
namespace internal {
template<class N>

View file

@ -5,6 +5,8 @@
using namespace mstch;
std::function<std::string(const std::string&)> mstch::config::escape;
std::string mstch::render(
const std::string& tmplt,
const node& root,

View file

@ -1,4 +1,5 @@
#include "utils.hpp"
#include "mstch/mstch.hpp"
mstch::citer mstch::first_not_ws(mstch::citer begin, mstch::citer end) {
for (auto it = begin; it != end; ++it)
@ -17,6 +18,9 @@ mstch::criter mstch::reverse(mstch::citer it) {
}
std::string mstch::html_escape(const std::string& str) {
if (mstch::config::escape)
return mstch::config::escape(str);
std::string out;
citer start = str.begin();