mwunsch / handlebars.scala

A Scala implementation of the Handlebars templating language (a superset of Mustache).
Apache License 2.0
112 stars 40 forks source link

Problem multiple Objects #54

Closed bastiankemmer closed 8 years ago

bastiankemmer commented 8 years ago

I've got this Template:

{{#ScreenProperties}}
{
    "controllerName":"{{&AppName}}.controller.{{&name}}",
    "height": "100%",
        "width" : "100%",
    "content": [{
        "title":"{{&name}}",
                "showHeader" : {{&showHeader}},
        "content":[
                {{& ScreenContent}}
         ]
    }]
}
{{/ScreenProperties}}

and this is my JSON:

{
  "AppName": "Demo1",
  "ScreenContent": "Hello World",
  "ScreenProperties": {
    "name": "Screen1",
    "showHeader": true
  }
}

When I try to fill my Template, this is the result:

{
    "controllerName": ".controller.Screen1",
    "height": "100%",
    "width": "100%",
    "content": [
        {
            "title": "Screen1",
            "showHeader": true,
            "content": []
        }
    ]
}

But when I try to fill it via Try Mustache, it will give me the right Result. Why does the behavior differ in this context?

PS: I know when my Template would look like that:

{
    "controllerName":"{{&AppName}}.controller.{{#ScreenProperties}}{{&name}}",
    "height": "100%",
        "width" : "100%",
    "content": [{
        "title":"{{&name}}",
                "showHeader" : {{&showHeader}},
                 {{/ScreenProperties}}
        "content":[
                {{& ScreenContent}}
         ]
    }]
}

it would work.

PS²: Well, I got the reason, this post can be closed.

timcharper commented 8 years ago

Which binding strategy were you using?

Glad you got it figured out.