Closed ghost closed 7 years ago
By default SmartFormat.NET uses {{ and }} for escaping braces in favor of compatibility with string.Format
. However, this does not work very well with nested placeholders, So it is recommended to set Smart.Default.Parser.UseBraceEscaping()
and escape braces with \{
or \}
respectively. \
is the alternative escape character. Have a look at the Wiki / Common Pitfalls for more details. Let me know if this has worked in your case as well, please.
So in short: Set Smart.Default.Parser.UseBraceEscaping()
as soon as you're using complex formatters, use the default behavior in order to have string.Format
compatibility.
Thank you so much 👍
There is problem with double ending braces parsing. E.g if I provide
Account {Type:choose(Days|Entries):days balance: {Value}|entries left: {Value} {Value:plural(en):entry|entries}|expiration date: {Value:d}}
as a format string, the result is not satisfying. When I divide two braces with space (egAccount {Type:choose(Days|Entries):days balance: {Value}|entries left: {Value} {Value:plural(en):entry|entries}|expiration date: {Value:d} }
) everything works pretty well except that the space is also in result string. I think it is a bug and wanted you to know about it.