Skip to content

Commit 55031bb

Browse files
authored
chore: update docs with imports (#402)
1 parent 437ecd4 commit 55031bb

File tree

1 file changed

+97
-40
lines changed

1 file changed

+97
-40
lines changed

README.md

Lines changed: 97 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,13 @@ ember install ember-cli-string-helpers
5353

5454
Camelizes a string using `Ember.String.camelize`.
5555

56-
```hbs
57-
{{camelize "hello jim bob"}}
58-
{{camelize stringWithDashes}}
56+
```gjs
57+
import { camelize } from 'ember-cli-string-helpers';
58+
59+
<template>
60+
{{camelize "hello jim bob"}}
61+
{{camelize stringWithDashes}}
62+
</template>
5963
```
6064

6165
Output: `helloJimBob`
@@ -66,9 +70,13 @@ Output: `helloJimBob`
6670

6771
Capitalizes a string using `Ember.String.capitalize`.
6872

69-
```hbs
70-
{{capitalize "hello jim bob"}}
71-
{{capitalize fullName}}
73+
```gjs
74+
import { capitalize } from 'ember-cli-string-helpers';
75+
76+
<template>
77+
{{capitalize "hello jim bob"}}
78+
{{capitalize fullName}}
79+
</template>
7280
```
7381

7482
Output: `Hello jim bob`
@@ -79,9 +87,13 @@ Output: `Hello jim bob`
7987

8088
Classifies a string using `Ember.String.classify`.
8189

82-
```hbs
83-
{{classify "hello jim bob"}}
84-
{{classify stringWithDashes}}
90+
```gjs
91+
import { classify } from 'ember-cli-string-helpers';
92+
93+
<template>
94+
{{classify "hello jim bob"}}
95+
{{classify stringWithDashes}}
96+
</template>
8597
```
8698

8799
Output: `HelloJimBob`
@@ -110,15 +122,28 @@ Mark a string as safe for unescaped output with Ember templates using `Ember.Str
110122
{{html-safe unsafeString}}
111123
```
112124

125+
```gjs
126+
import { htmlSafe } from 'ember-cli-string-helpers';
127+
128+
<template>
129+
{{htmlSafe "<div>someString</div>"}}
130+
{{htmlSafe unsafeString}}
131+
</template>
132+
```
133+
113134
**[⬆️ back to top](#available-helpers)**
114135

115136
#### `humanize`
116137

117138
Removes dashes and underscores from a string, capitalizes the first letter and makes the rest of the string lower case.
118139

119-
```hbs
120-
{{humanize "some-string"}}
121-
{{humanize phrase}}
140+
```gjs
141+
import { humanize } from 'ember-cli-string-helpers';
142+
143+
<template>
144+
{{humanize "some-string"}}
145+
{{humanize phrase}}
146+
</template>
122147
```
123148

124149
Output: `Some string`
@@ -129,9 +154,13 @@ Output: `Some string`
129154

130155
Lowercases a string.
131156

132-
```hbs
133-
{{lowercase "People Person's Paper People"}}
134-
{{lowercase phrase}}
157+
```gjs
158+
import { lowercase } from 'ember-cli-string-helpers';
159+
160+
<template>
161+
{{lowercase "People Person's Paper People"}}
162+
{{lowercase phrase}}
163+
</template>
135164
```
136165

137166
Output: `people person's paper people`
@@ -142,9 +171,13 @@ Output: `people person's paper people`
142171

143172
Capitalizes every word separated by a white space or a dash.
144173

145-
```hbs
146-
{{titleize "my big fat greek wedding"}}
147-
{{titleize phrase}}
174+
```gjs
175+
import { titleize } from 'ember-cli-string-helpers';
176+
177+
<template>
178+
{{titleize "my big fat greek wedding"}}
179+
{{titleize phrase}}
180+
</template>
148181
```
149182

150183
Output: `My Big Fat Greek Wedding`
@@ -155,9 +188,13 @@ Output: `My Big Fat Greek Wedding`
155188

156189
Trim a string.
157190

158-
```hbs
159-
{{trim " Lorem ipsum dolor sit amet, consectetur adipiscing elit. "}}
160-
{{trim phrase}}
191+
```gjs
192+
import { trim } from 'ember-cli-string-helpers';
193+
194+
<template>
195+
{{trim " Lorem ipsum dolor sit amet, consectetur adipiscing elit. "}}
196+
{{trim phrase}}
197+
</template>
161198
```
162199

163200
Output: `Lorem ipsum dolor sit amet, consectetur adipiscing elit.`
@@ -166,9 +203,13 @@ Output: `Lorem ipsum dolor sit amet, consectetur adipiscing elit.`
166203

167204
Truncates a string with a characterLimit and optionally adds an ellipsis to the end.
168205

169-
```hbs
170-
{{truncate "Lorem ipsum dolor sit amet, consectetur adipiscing elit." 20 true}}
171-
{{truncate phrase characterLimit useEllipsis}}
206+
```gjs
207+
import { truncate } from 'ember-cli-string-helpers';
208+
209+
<template>
210+
{{truncate "Lorem ipsum dolor sit amet, consectetur adipiscing elit." 20 true}}
211+
{{truncate phrase characterLimit useEllipsis}}
212+
</template>
172213
```
173214

174215
Output: `Lorem ipsum dolor...`
@@ -179,9 +220,13 @@ Output: `Lorem ipsum dolor...`
179220

180221
Underscores a string using `Ember.String.underscore`.
181222

182-
```hbs
183-
{{underscore "whatsThat"}}
184-
{{underscore phrase}}
223+
```gjs
224+
import { underscore } from 'ember-cli-string-helpers';
225+
226+
<template>
227+
{{underscore "whatsThat"}}
228+
{{underscore phrase}}
229+
</template>
185230
```
186231

187232
Output: `whats_that`
@@ -192,9 +237,13 @@ Output: `whats_that`
192237

193238
Uppercases a string.
194239

195-
```hbs
196-
{{uppercase "loud noises"}}
197-
{{uppercase phrase}}
240+
```gjs
241+
import { uppercase } from 'ember-cli-string-helpers';
242+
243+
<template>
244+
{{uppercase "loud noises"}}
245+
{{uppercase phrase}}
246+
</template>
198247
```
199248

200249
Output: `LOUD NOISES`
@@ -205,21 +254,29 @@ Output: `LOUD NOISES`
205254

206255
Splits a string on whitespace and/or turns multiple words into an array.
207256

208-
```hbs
209-
{{#each (w "First" "Second" "Last") as |rank|}}
210-
Our {{rank}} place winner is ...
211-
{{/each}}
257+
```gjs
258+
import { w } from 'ember-cli-string-helpers';
259+
260+
<template>
261+
{{#each (w "First" "Second" "Last") as |rank|}}
262+
Our {{rank}} place winner is ...
263+
{{/each}}
264+
</template>
212265
```
213266

214267
or:
215268

216-
```hbs
217-
{{#each (w "First Second Last") as |rank|}}
218-
Our {{rank}} place winner is ...
219-
{{/each}}
269+
```gjs
270+
import { w } from 'ember-cli-string-helpers';
271+
272+
<template>
273+
{{#each (w "First Second Last") as |rank|}}
274+
Our {{rank}} place winner is ...
275+
{{/each}}
276+
</template>
220277
```
221278

222-
See also: [Ember `w` documentation](https://api.emberjs.com/ember/release/classes/String/methods/w?anchor=w)
279+
See also: [Ember `w` documentation](https://api.emberjs.com/ember/4.9/classes/String/methods/w?anchor=w)
223280

224281
**[⬆️ back to top](#available-helpers)**
225282

@@ -254,7 +311,7 @@ import { camelize } from 'ember-cli-string-helpers';
254311

255312
## See also
256313

257-
* [ember-composable-helpers](https://github.com/dockyard/ember-composable-helpers)
314+
* [ember-composable-helpers](https://github.com/NullVoxPopuli/ember-composable-helpers)
258315
* [ember-math-helpers](https://github.com/RobbieTheWagner/ember-math-helpers)
259316
* [ember-truth-helpers](https://github.com/jmurphyau/ember-truth-helpers)
260317

0 commit comments

Comments
 (0)