mustache-sharp
mustache-sharp copied to clipboard
{{#if}} does not work with JObject
Example from immediate mode:
var d = new JObject();
Expression has been evaluated and has no value
d["test"] = "hello";
{hello}
First: '(d["test"] = "hello").First' threw an exception of type 'System.InvalidOperationException'
HasValues: false
Last: '(d["test"] = "hello").Last' threw an exception of type 'System.InvalidOperationException'
Newtonsoft.Json.IJsonLineInfo.LineNumber: 0
Newtonsoft.Json.IJsonLineInfo.LinePosition: 0
Next: null
Parent: {"test": "hello"}
Path: "test"
Previous: null
Root: {{
"test": "hello"
}}
Type: String
Value: "hello"
_annotations: null
_next: null
_parent: {"test": "hello"}
_previous: null
_value: "hello"
_valueType: String
Results View: Expanding the Results View will enumerate the IEnumerable
Dynamic View: Expanding the Dynamic View will get the dynamic members for the object
new Mustache.FormatCompiler().Compile("{{#if test}}{{test}} test{{/if}}").Render(d)
""
var d2 = new Dictionary<string,string> { { "test", "hello" } };
Expression has been evaluated and has no value
new Mustache.FormatCompiler().Compile("{{#if test}}{{test}} test{{/if}}").Render(d2)
"hello test"
new Mustache.FormatCompiler().Compile("{{test}} test").Render(d)
"hello test"
Newtonsoft v11.0 mustache-sharp v1.0