From 57196d08c52bc73bd923b830a2e59f86d55d8d7c Mon Sep 17 00:00:00 2001 From: Daniel Sipka Date: Mon, 1 Feb 2016 20:41:33 +0100 Subject: [PATCH] overridable escape function --- include/mstch/mstch.hpp | 4 ++++ src/mstch.cpp | 2 ++ src/utils.cpp | 4 ++++ 3 files changed, 10 insertions(+) diff --git a/include/mstch/mstch.hpp b/include/mstch/mstch.hpp index 6847528..58d3330 100644 --- a/include/mstch/mstch.hpp +++ b/include/mstch/mstch.hpp @@ -10,6 +10,10 @@ namespace mstch { +struct config { + static std::function escape; +}; + namespace internal { template diff --git a/src/mstch.cpp b/src/mstch.cpp index 8851aca..4d84e97 100644 --- a/src/mstch.cpp +++ b/src/mstch.cpp @@ -5,6 +5,8 @@ using namespace mstch; +std::function mstch::config::escape; + std::string mstch::render( const std::string& tmplt, const node& root, diff --git a/src/utils.cpp b/src/utils.cpp index 032f89a..1646170 100644 --- a/src/utils.cpp +++ b/src/utils.cpp @@ -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();