Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save 3gwebtrain/6a71cd1fd3dea7e529294bda45a7deca to your computer and use it in GitHub Desktop.
Save 3gwebtrain/6a71cd1fd3dea7e529294bda45a7deca to your computer and use it in GitHub Desktop.
Partial Template
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle'
});
import Ember from 'ember';
export default Ember.Controller.extend({
});
import Ember from 'ember';
export default Ember.Controller.extend({
appCont: Ember.inject.controller('application'),
myComponentName: Ember.computed('appCont.currentRouteName', function(){
let lastDotIndex = this.get('appCont.currentRouteName').lastIndexOf('.');
let myComponentName = this.get('appCont.currentRouteName').substring(lastDotIndex + 1);
if(myComponentName === 'index'){
return null;
}
myComponentName += '-header';
return myComponentName;
})
});
import Ember from 'ember';
export default Ember.Controller.extend({
});
import Ember from 'ember';
import config from './config/environment';
const Router = Ember.Router.extend({
location: 'none',
rootURL: config.rootURL
});
Router.map(function() {
this.route('home', function(){
this.route('service');
this.route('contact');
});
});
export default Router;
import Ember from 'ember';
export default Ember.Route.extend({
});
import Ember from 'ember';
export default Ember.Route.extend({
});
import Ember from 'ember';
export default Ember.Route.extend({
});
body {
margin: 12px 16px;
font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
font-size: 12pt;
}
header{
border:2px solid red;
}
p.service{
background:yellow;
}
p.contact{
background:lightblue;
}
<h1>Welcome to {{appName}}</h1>
<ul>
{{currentRouteName}}
<li>{{#link-to 'home' }}Home{{/link-to}}</li>
<li>{{#link-to 'home.service' }}Service{{/link-to}}</li>
<li>{{#link-to 'home.contact' }}Contact{{/link-to}}</li>
</ul>
<br>
<br>
{{outlet}}
<br>
<br>
{{yield}}
<p class="contact">Partial content for contact to be maintained in separate page </p>
{{yield}}
<p class="service">Partial content for Service to be maintained in separate hbs file </p>
<p>This is contact page content</p>
<header>
<h2>Home page header </h2>
{{#if myComponentName}}
{{component myComponentName}}
{{/if}}
</header>
{{outlet}}
<p>This is service page content</p>
{
"version": "0.12.1",
"EmberENV": {
"FEATURES": {}
},
"options": {
"use_pods": false,
"enable-testing": false
},
"dependencies": {
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.3/jquery.js",
"ember": "2.12.0",
"ember-template-compiler": "2.12.0",
"ember-testing": "2.12.0"
},
"addons": {
"ember-data": "2.12.1"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment