If you are new to C++, adding new libraries (template or otherwise) to your installation will only increase the learning curve. This is something you can do simply, elegantly, and efficiently with the built-in features.
Unlike similar answers, this code makes only one pass over the input and scales well with large dictionaries:
// header
#include <map>
#include <sstream>
typedef std::map< std::string, std::string > subst_map;
// implementation
using namespace std;
string do_substitutions( string const &in, subst_map const &subst ) {
ostringstream out;
size_t pos = 0;
for (;;) {
size_t subst_pos = in.find( "{{", pos );
size_t end_pos = in.find( "}}", subst_pos );
if ( end_pos == string::npos ) break;
out.write( &* in.begin() + pos, subst_pos - pos );
subst_pos += strlen( "{{" );
subst_map::const_iterator subst_it
= subst.find( in.substr( subst_pos, end_pos - subst_pos ) );
if ( subst_it == subst.end() ) throw runtime_error( "undefined substitution" );
out << subst_it->second;
pos = end_pos + strlen( "}}" );
}
out << in.substr( pos, string::npos );
return out.str();
}
// usage
pair< string, string > substitutions_init[] = {
make_pair( "firstname", "homer" ),
make_pair( "lastname", "simpson" )
};
subst_map substitutions
( substitutions_init, substitutions_init + sizeof(substitutions_init)/sizeof(*substitutions_init) );
int main() {
cerr << do_substitutions( "Mr. {{lastname}}, {{firstname}} esquire", substitutions ) << endl;
}