Skip to content

Instantly share code, notes, and snippets.

@hjumeau
Last active January 12, 2016 09:23
Show Gist options
  • Save hjumeau/c001109a7837394dedd9 to your computer and use it in GitHub Desktop.
Save hjumeau/c001109a7837394dedd9 to your computer and use it in GitHub Desktop.
RenderingATemplateExp
import Ember from 'ember';
export default Ember.Controller.extend({
appName:'Ember 2.0'
});
<h1>Welcome to {{appName}}</h1>
<br>
<br>
{{#link-to 'posts'}}posts{{/link-to}}
{{outlet}}
<br>
<br>
import Ember from 'ember';
export default Ember.Controller.extend({
});
import Ember from 'ember';
export default Ember.Route.extend({
renderTemplate(controller, model) {
// Render the `favoritePost` template into
// the outlet `posts`
var favoriteController = this.controllerFor('posts.favorite');
this.render('posts.favorite', {
into:'posts',
outlet: 'favorite',
controller: favoriteController,
model: model[0]
});
this.render('posts.index', {
into:'posts',
model:model,
controller: controller
});
}
});
{{#each model as |post|}}
<div>
{{post}}
</div>
{{/each}}
import Ember from 'ember';
export default Ember.Route.extend({
model(){
return ['Ember is awsome',
'Ember is fast and furious',
'Ember is very awsome'];
}
});
<div class='posts'>
{{outlet}}
</div>
<div class='favorite'>
{{outlet 'favorite'}}
</div>
import Ember from 'ember';
import config from './config/environment';
const Router = Ember.Router.extend({
location: config.locationType
});
Router.map(function() {
this.route('posts', function () {
this.route('favorite');
});
});
export default Router;
body {
margin: 12px 16px;
font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
font-size: 12pt;
}
.posts, .favorite {
display: table-cell;
padding: 10px;
}
{
"version": "0.5.0",
"EmberENV": {
"FEATURES": {}
},
"options": {
"enable-testing": false
},
"dependencies": {
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.3/jquery.js",
"ember": "https://cdnjs.cloudflare.com/ajax/libs/ember.js/2.2.0/ember.debug.js",
"ember-data": "https://cdnjs.cloudflare.com/ajax/libs/ember-data.js/2.2.0/ember-data.js",
"ember-template-compiler": "https://cdnjs.cloudflare.com/ajax/libs/ember.js/2.2.0/ember-template-compiler.js"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment