Skip to content

Instantly share code, notes, and snippets.

@oshikryu
Created April 28, 2015 21:42
Show Gist options
  • Save oshikryu/58792da01a6633d79898 to your computer and use it in GitHub Desktop.
Save oshikryu/58792da01a6633d79898 to your computer and use it in GitHub Desktop.
sample ember
App = Ember.Application.create();
App.Router.map(function() {
this.resource('all');
this.resource('recent');
this.resource('starred');
});
App.IndexRoute = Ember.Route.extend({
beforeModel: function() {
this.transitionTo('all');
}
});
App.AllRoute = Ember.Route.extend({
model: function() {
return diagrams;
}
});
App.RecentRoute = Ember.Route.extend({
model: function() {
return diagrams.slice(7);
}
});
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>EmberTest</title>
<link rel="stylesheet" href="css/normalize.css">
<link rel="stylesheet" href="css/simple.css">
</head>
<body>
<script type="text/x-handlebars">
<section id="sidebar">
<ul id="sidebar-menu">
<li>{{#link-to 'all'}}All{{/link-to}}</li>
<li>{{#link-to 'recent'}}Recent{{/link-to}}</li>
<li>{{#link-to 'starred'}}Starred{{/link-to}}</li>
</ul>
</section>
{{outlet}}
</script>
<script type="text/x-handlebars" id="all">
{{partial 'diagram-list'}}
</script>
<script type="text/x-handlebars" id="recent">
{{partial 'diagram-list'}}
</script>
<script type="text/x-handlebars" id="diagram-list">
<section id="content">
<ul>
{{#each}}
<li class="diagram">
<img src="http://placekitten.com/250/350" class="thumbnail">
<div class="text-container">
<h4 class="title">{{title}}</h4>
<h6 class="date">{{modified}}</h6>
<div class="button-box">
<img src="images/icn_private.png">
<img src="images/icn_star_off.png">
</div>
</div>
</li>
{{/each}}
</ul>
</section>
</script>
<script src="js/libs/jquery-1.10.2.js"></script>
<script src="js/libs/handlebars-1.1.2.js"></script>
<script src="js/libs/ember-1.7.0.js"></script>
<script src="js/libs/moment-2.8.3.js"></script>
<script src="js/app.js"></script>
<!-- to activate the test runner, add the "?test" query string parameter -->
<script src="tests/runner.js"></script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment