I am trying to build a Rails application with backbone.js templates and a mustache. I find that the JSON required by the backbone is incompatible with the JSON required by Usach. (I started with this tutorial, the Cloudedit -a backbone.js tutorial is an example , but I want to use Mustache, where it uses JST.
For the trunk, we must set ActiveRecord :: Base.include_root_in_json = false. For my model (a person with a first and last name), the data sent by the rails from / people looks like this:
[{"firstname":"Jane","surname":"Jones"},{"firstname":"Janet","surname":"Jensen"}]
My mustache pattern is as follows:
<h3><a href='#new'>Create New</a></h3>
<h4>People</h4>
<ul>
{{#people}}
<li>{{firstname}} {{surname}}</li>
{{/people}}
</ul>
and from the documents of the mustache I expect that what he wants to see
{"people":[{"firstname":"Jane","surname":"Jones"},{"firstname":"Janet","surname":"Jensen"}]}
, JS JSON Mustache.
. Mustache.js js-, JSON.
Mustache.to_html . firstname surname. firebug:
collection
+_byCid
+_byId
length 2
- models [object { attributes=(...), more...}, object {attributes=(...), more...}]
- 0 object { attributes=(...), more...}
....... some more properties of the object
+ attributes object {firstname="Janet", surname="Jensen"}
, .
1. (). , -, , {{#models}}.. {{/models}} .
- , Mustache.js. "firstname" , ['firstname'] , object.attributes ['firstname'] .
, ... ? ?