Blang/tools/mustache/src/mustache.cpp

18 lines
456 B
C++
Raw Normal View History

2016-04-22 21:46:31 +02:00
#include <regex>
#include <string>
#include "mustache/mustache.hpp"
std::string Mustache::render(const std::string& tmplt,const std::map<std::string,std::string>& context)
{
std::string result = tmplt;
for(std::map<std::string,std::string>::const_iterator it=context.begin(); it!=context.end(); ++it)
{
std::regex reg("\\{\\{"+it->first+"\\}\\}");
result = std::regex_replace(result,reg,std::string(it->second));
}
return result;
}