-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #169 from peopledoc/breaking/use-slugify-and-emoji…
…json
- Loading branch information
Showing
10 changed files
with
1,345 additions
and
1,140 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,27 @@ | ||
import { helper } from '@ember/component/helper' | ||
import { slugify as slugfyFunction } from 'ember-slugify' | ||
|
||
const AVAILABLE_OPTIONS = [ | ||
'replacement', // replace spaces with replacement character (string) | ||
'remove', // remove characters that match regex (regexp) | ||
'lower', // convert to lower case (boolean) | ||
'locale', //language code of the locale to use (string) | ||
'trim', // trim leading and trailing replacement chars (boolean) | ||
'pinyin', // replace chinese by latin character following the pinyin method (boolean) | ||
'emoji', // replace unicode emoji by it's description (boolean) | ||
] | ||
|
||
function slugify(args) { | ||
let [string] = args | ||
return slugfyFunction(string) | ||
let [string, options] = args | ||
let opts = {} | ||
if (options) { | ||
AVAILABLE_OPTIONS.forEach((key) => { | ||
if (options[key] !== undefined) { | ||
opts[key] = options[key] | ||
} | ||
}) | ||
} | ||
return slugfyFunction(string, opts) | ||
} | ||
|
||
export default helper(slugify) |
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
.block { | ||
margin-bottom: 40px; | ||
} | ||
|
||
.code { | ||
font-weight: bold; | ||
font-family: monospace; | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,30 @@ | ||
{{page-title "Dummy"}} | ||
{{page-title "ember-slugify"}} | ||
|
||
<h2 id="title">Welcome to Ember</h2> | ||
<h2 id="title">Welcome to ember-slugify</h2> | ||
|
||
<div class="block"> | ||
<p class="code">\{{slugify "Le Théâtre"}}</p> | ||
<p>{{slugify "Le Théâtre"}}</p> | ||
</div> | ||
|
||
<div class="block"> | ||
<p class="code">\{{slugify "I ♥ New York"}}</p> | ||
<p>{{slugify "I ♥ New York"}}</p> | ||
</div> | ||
|
||
<div class="block"> | ||
<p class="code">\{{slugify "你好你怎么样 monsieur" (hash pinyin=true)}}</p> | ||
<p>{{slugify "你好你怎么样 monsieur" (hash pinyin=true)}}</p> | ||
</div> | ||
|
||
<div class="block"> | ||
<p class="code">\{{slugify "🇫🇷❤️🥖➕🍷" (hash emoji=true)}}</p> | ||
<p>{{slugify "🇫🇷❤️🥖➕🍷" (hash emoji=true)}}</p> | ||
</div> | ||
|
||
<div class="block"> | ||
<p class="code">\{{remove-diacritics "Le Théâtre"}}</p> | ||
<p>{{remove-diacritics "Le Théâtre"}}</p> | ||
</div> | ||
|
||
{{outlet}} |
This file contains 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
This file contains 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
This file contains 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
Oops, something went wrong.