jehugaleahsa / mustache-sharp

An extension of the mustache text template engine for .NET.
The Unlicense
306 stars 80 forks source link

{{ }} around property with spaces in the name #82

Closed ghost closed 6 years ago

ghost commented 6 years ago

Hi - are spaces in the property names possible / is there some way to specify a literal key reference?

ie

modelDictionary = [
'Prop with Spaces':{
value: 'some string';
}
] //oversimplification of c# dictionary

...

var compiler = new FormatCompiler();
var generator = compiler.Compile(@"{{Prop with Spaces}}");
var name = generator.Render(modelDictionary);
//where name is now 'some string'

In the above example, mustache# doesnt find the key in the render step and value of name ends up being {{Prop with Spaces}}

In the readme overview of mustache-sharp handlebarsjs is mentioned... its not clear to me how literal this is to be taken but heres how its handled in handlebarsjs (doesnt work w/ mustache-sharp): https://github.com/wycats/handlebars.js/issues/358

jehugaleahsa commented 6 years ago

One restriction mustache# has always had is that property names must be valid C# property names. This is primarily because it does not discern between dictionaries and objects when looking up values, so it couldn't know if spaces should be valid in one case but not the other.

ghost commented 6 years ago

@jehugaleahsa thank you for your quick response