Skip to content

Instantly share code, notes, and snippets.

@ttdonovan
Forked from anonymous/index.html
Created May 26, 2015 21:30
Show Gist options
  • Save ttdonovan/f5283f44e7b1024a6fb2 to your computer and use it in GitHub Desktop.
Save ttdonovan/f5283f44e7b1024a6fb2 to your computer and use it in GitHub Desktop.
<!DOCTYPE html>
<html>
<head>
<script src="https://rawgit.com/lodash/lodash/3.0.1/lodash.min.js"></script>
<meta charset="utf-8">
<title>Ember Starter Kit</title>
<link rel="stylesheet" href="http://cdnjs.cloudflare.com/ajax/libs/normalize/3.0.1/normalize.css">
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script src="http://builds.emberjs.com/tags/v1.11.3/ember-template-compiler.js"></script>
<script src="http://builds.emberjs.com/tags/v1.11.3/ember.debug.js"></script>
<style id="jsbin-css">
/* Put your CSS here */
html, body {
margin: 20px;
}
</style>
</head>
<body>
<script type="text/x-handlebars">
<h2>Welcome to Ember.js</h2>
{{outlet}}
</script>
<script type="text/x-handlebars" data-template-name="index">
{{#link-to 'books'}}Random Book{{/link-to}}
<ul>
{{#each model as |book|}}
<li>{{#link-to 'books.book' book}}{{book.title}}{{/link-to}}</li>
{{/each}}
</ul>
</script>
<script type="text/x-handlebars" data-template-name="books/book">
Current Book: {{model.title}}
{{#link-to 'index'}}HOME{{/link-to}}
</script>
<script id="jsbin-javascript">
App = Ember.Application.create({
// Basic logging, e.g. "Transitioned into 'post'"
//LOG_TRANSITIONS: true,
// Extremely detailed logging, highlighting every internal
// step made while transitioning into a route, including
// `beforeModel`, `model`, and `afterModel` hooks, and
// information about redirects and aborted transitions
LOG_TRANSITIONS_INTERNAL: true
});
App.Book = Ember.Object.extend({
title: null
});
App.store = Ember.A([
App.Book.create({slug: 'book-1', title: 'Book 1'}),
App.Book.create({slug: 'book-2', title: 'Book 2'}),
App.Book.create({slug: 'book-3', title: 'Book 3'})
]);
App.Router.map(function() {
this.resource('books', function() {
this.route('book', { path: ':book_slug' });
});
});
App.IndexRoute = Ember.Route.extend({
model: function() {
return App.store;
}
});
App.BooksRoute = Ember.Route.extend({
model: function() {
return App.store;
},
// // only want to execute setupController if the path is '/books', not '/books/book-1'
// setupController: function(controller, model) {
// var sampleIndex = _.random(0, model.get('length') - 1);
// this.transitionTo('books.book', model.objectAt(sampleIndex).get('slug'));
// }
});
App.BooksBookRoute = Ember.Route.extend({
model: function(params) {
return _.find(App.store, function(book) {
return book.get('slug') === params.book_slug;
});
}
});
</script>
<script id="jsbin-source-html" type="text/html"><!DOCTYPE html>
<html>
<head>
<script src="https://rawgit.com/lodash/lodash/3.0.1/lodash.min.js"><\/script>
<meta charset="utf-8">
<title>Ember Starter Kit</title>
<link rel="stylesheet" href="http://cdnjs.cloudflare.com/ajax/libs/normalize/3.0.1/normalize.css">
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"><\/script>
<script src="http://builds.emberjs.com/tags/v1.11.3/ember-template-compiler.js"><\/script>
<script src="http://builds.emberjs.com/tags/v1.11.3/ember.debug.js"><\/script>
</head>
<body>
<script type="text/x-handlebars">
<h2>Welcome to Ember.js</h2>
{{outlet}}
<\/script>
<script type="text/x-handlebars" data-template-name="index">
{{#link-to 'books'}}Random Book{{/link-to}}
<ul>
{{#each model as |book|}}
<li>{{#link-to 'books.book' book}}{{book.title}}{{/link-to}}</li>
{{/each}}
</ul>
<\/script>
<script type="text/x-handlebars" data-template-name="books/book">
Current Book: {{model.title}}
{{#link-to 'index'}}HOME{{/link-to}}
<\/script>
</body>
</html>
</script>
<script id="jsbin-source-css" type="text/css">/* Put your CSS here */
html, body {
margin: 20px;
}
</script>
<script id="jsbin-source-javascript" type="text/javascript">App = Ember.Application.create({
// Basic logging, e.g. "Transitioned into 'post'"
//LOG_TRANSITIONS: true,
// Extremely detailed logging, highlighting every internal
// step made while transitioning into a route, including
// `beforeModel`, `model`, and `afterModel` hooks, and
// information about redirects and aborted transitions
LOG_TRANSITIONS_INTERNAL: true
});
App.Book = Ember.Object.extend({
title: null
});
App.store = Ember.A([
App.Book.create({slug: 'book-1', title: 'Book 1'}),
App.Book.create({slug: 'book-2', title: 'Book 2'}),
App.Book.create({slug: 'book-3', title: 'Book 3'})
]);
App.Router.map(function() {
this.resource('books', function() {
this.route('book', { path: ':book_slug' });
});
});
App.IndexRoute = Ember.Route.extend({
model: function() {
return App.store;
}
});
App.BooksRoute = Ember.Route.extend({
model: function() {
return App.store;
},
// // only want to execute setupController if the path is '/books', not '/books/book-1'
// setupController: function(controller, model) {
// var sampleIndex = _.random(0, model.get('length') - 1);
// this.transitionTo('books.book', model.objectAt(sampleIndex).get('slug'));
// }
});
App.BooksBookRoute = Ember.Route.extend({
model: function(params) {
return _.find(App.store, function(book) {
return book.get('slug') === params.book_slug;
});
}
});</script></body>
</html>
/* Put your CSS here */
html, body {
margin: 20px;
}
App = Ember.Application.create({
// Basic logging, e.g. "Transitioned into 'post'"
//LOG_TRANSITIONS: true,
// Extremely detailed logging, highlighting every internal
// step made while transitioning into a route, including
// `beforeModel`, `model`, and `afterModel` hooks, and
// information about redirects and aborted transitions
LOG_TRANSITIONS_INTERNAL: true
});
App.Book = Ember.Object.extend({
title: null
});
App.store = Ember.A([
App.Book.create({slug: 'book-1', title: 'Book 1'}),
App.Book.create({slug: 'book-2', title: 'Book 2'}),
App.Book.create({slug: 'book-3', title: 'Book 3'})
]);
App.Router.map(function() {
this.resource('books', function() {
this.route('book', { path: ':book_slug' });
});
});
App.IndexRoute = Ember.Route.extend({
model: function() {
return App.store;
}
});
App.BooksRoute = Ember.Route.extend({
model: function() {
return App.store;
},
// // only want to execute setupController if the path is '/books', not '/books/book-1'
// setupController: function(controller, model) {
// var sampleIndex = _.random(0, model.get('length') - 1);
// this.transitionTo('books.book', model.objectAt(sampleIndex).get('slug'));
// }
});
App.BooksBookRoute = Ember.Route.extend({
model: function(params) {
return _.find(App.store, function(book) {
return book.get('slug') === params.book_slug;
});
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment