18 lines
456 B
C++
18 lines
456 B
C++
#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;
|
|
}
|