Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Access route properties using getters #2

Merged
merged 3 commits into from
Feb 20, 2015
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 10 additions & 7 deletions vendor-addon/document-title/document-title.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
var get = Ember.get;

// Extend Ember.Route to add support for sensible
// document.title integration.
Ember.Route.reopen({
Expand All @@ -17,9 +19,9 @@ Ember.Route.reopen({
// Provided by Ember
_actions: {
collectTitleTokens: function(tokens) {
var titleToken = this.titleToken;
if (typeof this.titleToken === 'function') {
titleToken = this.titleToken(this.currentModel);
var titleToken = get(this, 'titleToken');
if (typeof titleToken === 'function') {
titleToken = titleToken(get(this, 'currentModel'));
}

if (Ember.isArray(titleToken)) {
Expand All @@ -30,14 +32,15 @@ Ember.Route.reopen({

// If `title` exists, it signals the end of the
// token-collection, and the title is decided right here.
if (this.title) {
var title = get(this, 'title');
if (title) {
var finalTitle;
if (typeof this.title === 'function') {
finalTitle = this.title(tokens);
if (typeof title === 'function') {
finalTitle = title(tokens);
} else {
// Tokens aren't even considered... a string
// title just sledgehammer overwrites any children tokens.
finalTitle = this.title;
finalTitle = title;
}

// Stubbable fn that sets document.title
Expand Down