Skip to content

Commit

Permalink
Merge pull request #931 from nlfurniss/patch-1
Browse files Browse the repository at this point in the history
add `htmlSafe` to list of deprecated string methods
  • Loading branch information
mixonic committed Aug 17, 2021
2 parents 7070428 + e4c75a5 commit cef383a
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion content/ember/v3/ember-string-prototype-extensions.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ since: '3.24'
anchor: toc_ember-string-prototype_extensions
---

Calling one of the [Ember `String` methods](https://api.emberjs.com/ember/3.22/classes/String) (camelize, capitalize, classify, dasherize, decamelize, underscore) directly on a string is deprecated.
Calling one of the [Ember `String` methods](https://api.emberjs.com/ember/3.22/classes/String) (camelize, capitalize, classify, dasherize, decamelize, htmlSafe, underscore) directly on a string is deprecated.

While Ember addons (`ember addon …`) have prototype extensions disabled by default, they are enabled for applications (`ember new …`) making you able to call `"Tomster".dasherize()`, for example.
Instead of calling the method on the string, you should instead import the function from `@ember/string`.
Expand All @@ -20,6 +20,7 @@ mascot.camelize(); //=> "empressZoey"
mascot.capitalize(); //=> "Empress Zoey"
mascot.classify(); //=> "EmpressZoey"
mascot.decamelize(); //=> "empress zoey"
mascot.htmlSafe(); //=> { string: "Empress Zoey" }
mascot.underscore(); //=> "empress_zoey"
mascot.w(); //=> [ "Empress", "Zoey" ]
```
Expand All @@ -35,13 +36,15 @@ import {
underscore,
w,
} from "@ember/string";
import { htmlSafe } from '@ember/template';

let mascot = "Empress Zoey";

camelize(mascot); //=> "empressZoey"
capitalize(mascot); //=> "Empress Zoey"
classify(mascot); //=> "EmpressZoey"
decamelize(mascot); //=> "empress zoey"
htmlSafe(mascot); //=> { string: "Empress Zoey" }
underscore(mascot); //=> "empress_zoey"
w(mascot); //=> [ "Empress", "Zoey" ]
```
Expand Down

0 comments on commit cef383a

Please sign in to comment.