cierelabs / boostache

Template engine library in C++
92 stars 62 forks source link

Provide a custom callback for tags/conditions/lists #13

Open KingDuckZ opened 9 years ago

KingDuckZ commented 9 years ago

Reading some of the other issues already open, and based on some old code I wrote which provides a custom specialization for get_variable_value(), I'm not really sure this is not possible yet. In short, client code should be able to provide a custom function that takes a string as input and returns whatever the translation of that string is.

I've been trying to implement this myself. My approach has been to look for an optional method std::string tag_callback(const std::string&) in the context provided to generate(). If current tag can't be found in the context, and tag_callback() is provided, I invoke it. This is working so far but I'm not 100% satisfied because:

I'm not sure I'm doing this the right way, comments are welcome.