-
Notifications
You must be signed in to change notification settings - Fork 50
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
partially render templates for improved performance? #67
Comments
|
For now I'm using std::regex_replace on the templates before passing them into mustache... Maybe later I'll come up with something better. This is a C++ framework so performance is usually pretty important for C++ devs, even if it's only a few percentage points improvement. |
If you have control of this template, you could maybe try the set delimiter tags and use different characters for the fields you want to pre-populate, then render that template with pre-populated fields, which would produce the final template for dynamic data. For example, render this with a "server" value:
which would then produce:
|
I'd like to pre-populate some fields in a template that will always be the same in order to improve performance. For example:
I'd like to prepopulate
{{server}}
since it will not change and this template will be generated potentially millions of times.My first naive attempt to do this looked like this:
kainjow::mustache::data global_data; global_data.set("server", get_hostname()); kainjow::mustache::mustache t = kainjow::mustache::mustache(template_str).render(global_data);
However this deletes the
{{user}}
field so the codet.render({ "user", provided_username });
results in
So, two questions:
"{{variable}}"
?Thanks!
The text was updated successfully, but these errors were encountered: