Skip to content
This repository was archived by the owner on Mar 29, 2026. It is now read-only.

{{#if}} does not work with JObject #93

Description

@dave-yotta

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions