Last active
April 6, 2016 17:26
-
-
Save grapho/be701fd69d04d94da1af8738f18c3755 to your computer and use it in GitHub Desktop.
Format Title
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Ember from 'ember'; | |
import { formatTitle } from '../helpers/format-title'; | |
export default Ember.Controller.extend({ | |
appName: 'format-title', | |
formattedTitle: Ember.computed('appName', { | |
get() { | |
return formatTitle(this.get('appName')); | |
} | |
}) | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Ember from 'ember'; | |
const { isPresent, isArray } = Ember; | |
const { dasherize, capitalize } = Ember.String; | |
export function formatTitle(titleArg, fixtures) { | |
let title = isArray(titleArg) ? titleArg[0] : titleArg; | |
let formatted; | |
if (isPresent(title)) { | |
console.log(title); | |
formatted = dasherize(title).split('-').map((word) => { | |
return capitalize(word); | |
}).join(' '); | |
} | |
if (isPresent(fixtures)) { | |
if (isPresent(fixtures.prefix)) { | |
formatted = `${fixtures.prefix} ${formatted}`; | |
} | |
if (isPresent(fixtures.suffix)) { | |
formatted = `${formatted} ${fixtures.suffix}`; | |
} | |
} | |
return formatted; | |
} | |
export default Ember.Helper.helper(formatTitle); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"version": "0.7.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": "https://cdnjs.cloudflare.com/ajax/libs/ember.js/2.4.3/ember.debug.js", | |
"ember-data": "https://cdnjs.cloudflare.com/ajax/libs/ember-data.js/2.4.3/ember-data.js", | |
"ember-template-compiler": "https://cdnjs.cloudflare.com/ajax/libs/ember.js/2.4.3/ember-template-compiler.js" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment