Access Nested Backbone Model Attributes from Mustache Template

后端 未结 4 813
不思量自难忘°
不思量自难忘° 2020-12-28 21:50

I have one Backbone model which has an attribute that is a reference to another Backbone model. For example, a Person has a reference to an Address object.

P         


        
4条回答
  •  星月不相逢
    2020-12-28 22:27

    Try using Handlebars, a templating engine based on Mustache with nested properties support.

    Then it would be as easy as {{Address/City}}.

    If you don't want to change your templating engine, you can flatten results from Address object and pass them as properties directly on the Person.

提交回复
热议问题