Closed art-ist closed 5 years ago
Could you write a unit test? I don't understand why the value you inject into the template should affect the outcome.
On Tue, Dec 11, 2018, 2:47 AM Michael Vesely <notifications@github.com wrote:
If a property of the data object (not the template) contains a single brace { or } or an empty string (instead of being null) the the exception After parsing a value an unexpected character was encountered is thrown. As I don't see any conflicts with the matching of mustache tags {{ or }} it would be great if the engine would 'survive' that kind of data.
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/jehugaleahsa/mustache-sharp/issues/86, or mute the thread https://github.com/notifications/unsubscribe-auth/ABTgPiotG0bMUAOZwXjpn_heN1-09-L1ks5u32MtgaJpZM4ZM1j1 .
I just submitted a pull request with those unit tests, you requested. And ... they all run through fine. So obviously I didn't pinpoint the issue well enough and was shooting a little early, sorry. I'll investigate the issue further. And if it is not domain specific but might be of interest (like in a note in the docs), I'll let you know. Thanks for pushing me in the right direction to narrow the problem down.
I've solved the issue now. And it was definitely not the fault of mustache#.
The reason was: I had built a custom TagDefinition for a template tag that allows to reuse sub-templates. override void GetText(TextWriter,
... expects a call like writer.Write(renderedString);
. But as I was passing a second parameter as well, I was calling a different overload: writer.Write(string format, object arg0)
witch is calling String.Format
internally. And, yes String.Format does have a problem with a format string like {color:red}
.
... but some additional unit tests souldn't do any harm :-)
If a property of the data object (not the template) contains a single brace
{
or}
or an empty string (instead of being null) the the exceptionAfter parsing a value an unexpected character was encountered
is thrown. As I don't see any conflicts with the matching of mustache tags{{
or}}
it would be great if the engine would 'survive' that kind of data.