ember.js - Layout for a group of Ember routes without affecting URL -



ember.js - Layout for a group of Ember routes without affecting URL -

let's have next router:

router.map(function() { this.route('intro'); this.route('about'); this.route('terms-of-use'); });

what want have parent template routes about , terms-of-use without modifying path, like:

router.map(function() { this.route('intro'); this.route('some-layout', /* 0 length path options */) { this.route('about'); this.route('terms-of-use'); } });

i considering putting flag on applicationcontroller , using in application template show different stuff intro , other routes. create mess.

then possible utilize custom base of operations route class about , terms-of-use overriden rendertemplate simulate parent template. wouldn't nice, configuration of template nesting spread across whole application.

it seems optimal in router, possible?

my current solution flag on applicationcontroller

anotherlayout: function() { homecoming ['about', 'terms-of-use'].indexof(this.currentroutename) !== -1; }.property('currentroutename')

unfortunately can't define route doesn't have url (well, can, when { path: '/' }, 1 time - won't do)

the news can specify view classes both about , terms-of-use.

app.aboutview = app.termsofuseview = ember.view.extend({ layoutname: 'some-layout' });

then some-layout handlebars template {{yield}} helper, so:

<div class="some-layout"> {{yield}} </div>

here how works: when ember renders route's template, first checks if there view class existing. if so, it'll set it's template property. since utilize layout property, won't overwritten. not quite perfect won't true parent these routes, in cases job.

also think ember back upwards feature described, since create perfect sense, , know lot of people suffer lack of (me included).

more layouts: http://emberjs.com/guides/views/adding-layouts-to-views/

ember.js

Comments

Popular posts from this blog

c - Compilation of a code: unkown type name string -

java - Bypassing "final local variable defined in an enclosing type" -

json - Hibernate and Jackson (java.lang.IllegalStateException: Cannot call sendError() after the response has been committed) -