hummingbird-project / swift-mustache

Mustache templating engine
Apache License 2.0
21 stars 2 forks source link

arrays of child objects #15

Closed JaapWijnen closed 2 years ago

JaapWijnen commented 2 years ago

Not 100% sure if this is expected to work like this but the following approach currently doesn't work although it seems natural to me.

struct Context {
    let name: String
    let properties: [Property]
}
struct Property {
   let name: String
   let type: String
}

with the following template

struct {{name}} {
    {{#properties}}
    // properties
    var {{name}}: {{type}}
    {{/properties}}
}

Currently only renders:

struct Thing {
    //properties
}

Maybe I shouldn't expect this to work? What would be the way to make this work?

JaapWijnen commented 2 years ago

100% my fault for referencing the wrong template, a similar copy 😅

adam-fowler commented 2 years ago

Yeah was just about to say it works for me.