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

add htmlSafe to list of deprecated string methods #931

Merged
merged 1 commit into from
Aug 17, 2021
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
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