Ember.js v0.9.7.1
HTML
<script src="https://github.com/downloads/emberjs/ember.js/ember-0.9.7.1.js"></script>
<script type="text/x-handlebars" data-template-name="app-server1">
<h1>Default</h1>
{{#each data.Servers}}
<div class="server">
<h1>{{unbound Name}}</h1>
Time: {{unbound CurrentTime}}<br />
<table>
{{#each Processes}}
<tr>
<td>{{unbound Name}}</td>
<td>{{unbound Location}}</td>
</tr>
{{/each}}
</table>
</div>
{{/each}}
<hr />
</script>
<script type="text/x-handlebars" data-template-name="app-server2a">
<h1>Fixed</h1>
{{#each data.Servers}}
<div class="server">
<h1>{{unbound Name}}</h1>
Time: {{unbound CurrentTime}}<br />
<table>
{{#Processes}}
<tr>
<td>{{unbound Name}}</td>
<td>{{unbound Location}}</td>
</tr>
{{/Processes}}
</table>
</div>
{{/each}}
<hr />
</script>
<script type="text/x-handlebars" data-template-name="app-server2b">
<h1>Fixed with undefined</h1>
{{#each data.Servers}}
<div class="server">
<h1>{{unbound Name}}</h1>
Time: {{unbound CurrentTime}}<br />
<table>
{{#Processes}}
<tr>
<!-- Note I didn't use anything from the object -->
<td>Name</td>
<td>Location</td>
</tr>
{{/Processes}}
</table>
</div>
{{/each}}
<hr />
</script>
<script type="text/x-handlebars" data-template-name="app-server3">
<h1>Outside</h1>
{{#each data.Servers}}
<div...
JavaScript
App = Ember.Application.create({
//For some reason ready isn't working here, gives error.
});
$(document).ready(function() {
App.ServerOverview1.append();
App.ServerOverview2a.append();
App.ServerOverview2b.append();
App.ServerOverview3.append();
App.Service.getServers();
});
App.Service = Ember.Namespace.create({
data: {},
getServers: function() {
this.set('data', {
"Servers":[
{"Name":"USWest","CurrentTime":"1337","Processes":
[
{"Name":"apache.exe","Location":"Somewhere","Modules":
[
{"Name":"php.exe"},
{"Name":"php.exe"},
{"Name":"php.exe"}
]},
{"Name":"mysql.exe","Location":"Somewhere","Modules":
[
{"Name":"php.exe"},
{"Name":"php.exe"},
{"Name":"php.exe"}
]},
{"Name":"phpmyadmin.exe","Location":"Somewhere","Modules":
[
{"Name":"php.exe"},
{"Name":"php.exe"},
{"Name":"php.exe"}
]}
]},
{"Name":"USEast","CurrentTime":"1337","Processes":
[
{"Name":"apache.exe","Location":"Somewhere","Modules":
[
{"Name":"php.exe"},
{"Name":"php.exe"},
{"Name":"php.exe"}
]},
{"Name":"mysql.exe","Location":"Somewhere","Modules":
[
{"Name":"php.exe"},
{"Name":"php.exe"},
{"Name":"php.exe"}
]},
{"Name":"phpmyadmin.exe","Location":"Somewhere","Modules":
[
...