StubbleOrg / Stubble

Trimmed down {{mustache}} templates in .NET
Other
399 stars 58 forks source link

Render variable names instead of empty strings? #113

Closed ivanyurchenko1 closed 3 years ago

ivanyurchenko1 commented 3 years ago

Hello,

This is not an issue but rather a question / feature request. We're using Stubble to render templates, and we don't know for certain which variables might be missing. We want to show user something like {{variable}} instead of an empty space in case the variable is missing, so at least he would be able to report this missing variable to us. Is it possible to configure / implement it in such a way?

Thank you!

Romanx commented 3 years ago

Hi there,

It currently not possible to do this. we have the property ThrowOnDataMiss on the render settings which rather than silently returning empty it will throw when a value is not found.

This felt like a good compromise to keep Stubble working identical to the mustache spec and allowing the user to have some saftey if they desired it.

ivanyurchenko1 commented 3 years ago

Thank you for the answer! I used ThrowOnDataMiss and added some logging to make sure we find the missing variables.

Romanx commented 3 years ago

Good to know this helped you!