@jaredwray/fumanchu 3.0.3 → 3.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/README.md +27 -3021
  2. package/dist/index.js +2 -2
  3. package/package.json +8 -8
package/README.md CHANGED
@@ -10,37 +10,36 @@ Handlebars + Helpers Together
10
10
  [![GitHub license](https://img.shields.io/github/license/jaredwray/fumanchu)](https://github.com/jaredwray/fumanchu/blob/master/LICENSE)
11
11
  [![npm](https://img.shields.io/npm/dm/@jaredwray/fumanchu)](https://npmjs.com/package/@jaredwray/fumanchu)
12
12
 
13
- [Handlebars](https://github.com/handlebars-lang/handlebars.js) + [Handlebars-helpers](https://github.com/helpers/handlebars-helpers) (helpers are now maintained in this project) combined into a single package. Easily use in your nodejs as it is a drop in replacement when using handlebars directly.
14
-
15
- We plan to make significant changes over time with this project such as the following:
16
- - **(Completed)** Remove all dependencies on `handlebars-helpers` and maintain all helpers in this project
17
- - **(Completed)** Migration to `vitest` as a testing framework
18
- - **(Completed)** Migration to `xo` as a linting framework
19
- - **(In Progress)** Migrate to Typescript with full typing support
20
- - **(In Progress)** Replace module dependencies that are no longer supported with supported ones
21
- - Migration to ESM and CJS support using cross compatible code
22
- - Move to better documentation and examples where it makes sense
23
- - Add in browser support via CDN (this will remove the nodejs specific helpers)
24
-
25
- # Breaking Changes from v2 to v3
26
-
27
- Because of the complexity in the legacy helpers library we have moved to exporting the libraries and a helper function to make it easier to use. Here are the exports:
28
-
29
- - `handlebars` - This is an instance of handlebars library without any helpers. It is the same as calling `Handlebars.create()`
30
- - `helpers` - This is a function that takes an object with a `handlebars` key and adds all the helpers to the handlebars instance. This is the same as calling `helpers({ handlebars: handlebars }, { ..options })`
31
- - `createHandlebars` - This is an async function that returns a handlebars instance with all the helpers added. This is the same as calling `helpers({ handlebars: handlebars }, { ..options })` but async.
32
- - `Handlebars` - This is the handlebars library itself. It is the same as calling `require('handlebars')`
33
-
34
- Please see the examples below for how to use the library.
13
+ [Handlebars](https://github.com/handlebars-lang/handlebars.js) + [Handlebars-helpers](https://github.com/helpers/handlebars-helpers) (helpers are now maintained in this project) combined into a single package. Easily use it as a drop in replacement when using handlebars directly. More than 180 Handlebars helpers in ~20 categories. Helpers can be used with Assemble, Generate, Verb, Ghost, gulp-handlebars, grunt-handlebars, consolidate, or any node.js/Handlebars project. Currently **189 helpers** in **20 categories**! 🎉
35
14
 
36
15
  # Table of Contents
37
16
  * [Using in Nodejs](#using-in-nodejs)
38
17
  * [Just using Handlebar Helpers](#using-handlebars-helpers)
39
- * [Helpers](#helpers)
18
+ * [Helpers](https://fumanchu.org/docs/helpers/)
19
+ * [array](https://fumanchu.org/docs/helpers/array/)
20
+ * [code](https://fumanchu.org/docs/helpers/code/)
21
+ * [comparison](https://fumanchu.org/docs/helpers/comparison/)
22
+ * [collection](https://fumanchu.org/docs/helpers/collection/)
23
+ * [date](https://fumanchu.org/docs/helpers/date/)
24
+ * [fs](https://fumanchu.org/docs/helpers/fs/)
25
+ * [html](https://fumanchu.org/docs/helpers/html/)
26
+ * [i18n](https://fumanchu.org/docs/helpers/i18n/)
27
+ * [inflection](https://fumanchu.org/docs/helpers/inflection/)
28
+ * [logging](https://github.com/jonathas/logging-helpers)
29
+ * [markdown](https://fumanchu.org/docs/helpers/markdown/)
30
+ * [match](https://fumanchu.org/docs/helpers/match/)
31
+ * [math](https://fumanchu.org/docs/helpers/math/)
32
+ * [misc](https://fumanchu.org/docs/helpers/misc/)
33
+ * [number](https://fumanchu.org/docs/helpers/number/)
34
+ * [object](https://fumanchu.org/docs/helpers/object/)
35
+ * [path](https://fumanchu.org/docs/helpers/path/)
36
+ * [regex](https://fumanchu.org/docs/helpers/regex/)
37
+ * [string](https://fumanchu.org/docs/helpers/string/)
38
+ * [url](https://fumanchu.org/docs/helpers/url/)
39
+ * [utils](https://fumanchu.org/docs/helpers/utils/)
40
40
  * [How to Contribute](#how-to-contribute)
41
41
  * [License and Copyright](#license-and-copyright)
42
42
 
43
-
44
43
  # Usage Nodejs
45
44
 
46
45
  ```bash
@@ -84,7 +83,8 @@ If you only want to use handlebar helpers you can easily do that by doing the fo
84
83
  ```javascript
85
84
  var {helpers} = require('@jaredwray/fumanchu');
86
85
  var handlebars = require('handlebars');
87
- helpers({ handlebars: handlebars });
86
+ var helpersFunction = await helpers();
87
+ helpersFunction({ handlebars: handlebars });
88
88
  var fn = handlebars.compile('{{add value 5}}');
89
89
  console.log(fn); // 10
90
90
  ```
@@ -94,3007 +94,13 @@ If using it with es6 you can access `helpers` via destructuring:
94
94
  ```javascript
95
95
  import {helpers} from '@jaredwray/fumanchu';
96
96
  import handlebars from 'handlebars';
97
- helpers({ handlebars: handlebars });
97
+ const helpersFunction = await helpers();
98
+ helpersFunction({ handlebars: handlebars });
98
99
  const template = handlebars.compile('{{#if (eq foo "bar")}}<p>Foo is bar</p>{{/if}}');
99
100
  const html = template({foo: 'bar'});
100
101
  console.log(html); // <p>Foo is bar</p>
101
102
  ```
102
103
 
103
- # Helpers
104
- More than 180 Handlebars helpers in ~20 categories. Helpers can be used with Assemble, Generate, Verb, Ghost, gulp-handlebars, grunt-handlebars, consolidate, or any node.js/Handlebars project.
105
-
106
- ## Categories
107
-
108
- Currently **189 helpers** in **20 categories**:
109
-
110
- * **[array](#array)** ([code](lib/array.js) | [unit tests](test/array.js))
111
- * **[code](#code)** ([code](lib/code.js) | [unit tests](test/code.js))
112
- * **[collection](#collection)** ([code](lib/collection.js) | [unit tests](test/collection.js))
113
- * **[comparison](#comparison)** ([code](lib/comparison.js) | [unit tests](test/comparison.js))
114
- * **[date](#date)** ([code](lib/date.js) | [unit tests](test/date.js))
115
- * **[fs](#fs)** ([code](lib/fs.js) | [unit tests](test/fs.js))
116
- * **[html](#html)** ([code](lib/html.js) | [unit tests](test/html.js))
117
- * **[i18n](#i18n)** ([code](lib/i18n.js) | [unit tests](test/i18n.js))
118
- * **[inflection](#inflection)** ([code](lib/inflection.js) | [unit tests](test/inflection.js))
119
- * **[logging](#logging)** ([code](lib/logging.js) | [unit tests](test/logging.js))
120
- * **[markdown](#markdown)** ([code](lib/markdown.js) | [unit tests](test/markdown.js))
121
- * **[match](#match)** ([code](lib/match.js) | [unit tests](test/match.js))
122
- * **[math](#math)** ([code](lib/math.js) | [unit tests](test/math.js))
123
- * **[misc](#misc)** ([code](lib/misc.js) | [unit tests](test/misc.js))
124
- * **[number](#number)** ([code](lib/number.js) | [unit tests](test/number.js))
125
- * **[object](#object)** ([code](lib/object.js) | [unit tests](test/object.js))
126
- * **[path](#path)** ([code](lib/path.js) | [unit tests](test/path.js))
127
- * **[regex](#regex)** ([code](lib/regex.js) | [unit tests](test/regex.js))
128
- * **[string](#string)** ([code](lib/string.js) | [unit tests](test/string.js))
129
- * **[url](#url)** ([code](lib/url.js) | [unit tests](test/url.js))
130
-
131
- # All helpers
132
-
133
- ### [array helpers](#array)
134
-
135
- Visit the: [code](lib/array.js) | [unit tests](test/array.js) | [issues](https://github.com/jonathas/handlebars-helpers/issues?utf8=%E2%9C%93&q=is%3Aissue+is%3Aopen+array+helpers))
136
-
137
- * **[after](#after)** ([code](lib/array.js#L22) | [tests](test/array.js#L13))
138
- * **[arrayify](#arrayify)** ([code](lib/array.js#L39) | [tests](test/array.js#L29))
139
- * **[before](#before)** ([code](lib/array.js#L58) | [tests](test/array.js#L36))
140
- * **[eachIndex](#eachIndex)** ([code](lib/array.js#L77) | [tests](test/array.js#L58))
141
- * **[filter](#filter)** ([code](lib/array.js#L102) | [tests](test/array.js#L91))
142
- * **[first](#first)** ([code](lib/array.js#L142) | [tests](test/array.js#L65))
143
- * **[forEach](#forEach)** ([code](lib/array.js#L184) | [tests](test/array.js#L123))
144
- * **[inArray](#inArray)** ([code](lib/array.js#L224) | [tests](test/array.js#L160))
145
- * **[isArray](#isArray)** ([code](lib/array.js#L244) | [tests](test/array.js#L172))
146
- * **[itemAt](#itemAt)** ([code](lib/array.js#L263) | [tests](test/array.js#L182))
147
- * **[join](#join)** ([code](lib/array.js#L294) | [tests](test/array.js#L225))
148
- * **[equalsLength](#equalsLength)** ([code](lib/array.js#L313) | [tests](test/array.js#L494))
149
- * **[last](#last)** ([code](lib/array.js#L349) | [tests](test/array.js#L240))
150
- * **[length](#length)** ([code](lib/array.js#L379) | [tests](test/array.js#L254))
151
- * **[lengthEqual](#lengthEqual)** ([code](lib/array.js#L395) | [tests](test/array.js#L254))
152
- * **[map](#map)** ([code](lib/array.js#L414) | [tests](test/array.js#L266))
153
- * **[pluck](#pluck)** ([code](lib/array.js#L445) | [tests](test/array.js#L300))
154
- * **[reverse](#reverse)** ([code](lib/array.js#L473) | [tests](test/array.js#L506))
155
- * **[some](#some)** ([code](lib/array.js#L504) | [tests](test/array.js#L308))
156
- * **[sort](#sort)** ([code](lib/array.js#L532) | [tests](test/array.js#L333))
157
- * **[sortBy](#sortBy)** ([code](lib/array.js#L557) | [tests](test/array.js#L358))
158
- * **[withAfter](#withAfter)** ([code](lib/array.js#L588) | [tests](test/array.js#L390))
159
- * **[withBefore](#withBefore)** ([code](lib/array.js#L618) | [tests](test/array.js#L397))
160
- * **[withFirst](#withFirst)** ([code](lib/array.js#L648) | [tests](test/array.js#L404))
161
- * **[withGroup](#withGroup)** ([code](lib/array.js#L692) | [tests](test/array.js#L418))
162
- * **[withLast](#withLast)** ([code](lib/array.js#L727) | [tests](test/array.js#L428))
163
- * **[withSort](#withSort)** ([code](lib/array.js#L766) | [tests](test/array.js#L442))
164
- * **[unique](#unique)** ([code](lib/array.js#L816) | [tests](test/array.js#L483))
165
-
166
- ### [code helpers](#code)
167
-
168
- Visit the: [code](lib/code.js) | [unit tests](test/code.js) | [issues](https://github.com/jonathas/handlebars-helpers/issues?utf8=%E2%9C%93&q=is%3Aissue+is%3Aopen+code+helpers))
169
-
170
- * **[embed](#embed)** ([code](lib/code.js#L23) | [tests](test/code.js#L10))
171
- * **[gist](#gist)** ([code](lib/code.js#L45) | [tests](test/code.js#L62))
172
- * **[jsfiddle](#jsfiddle)** ([code](lib/code.js#L60) | [tests](test/code.js#L69))
173
-
174
- ### [collection helpers](#collection)
175
-
176
- Visit the: [code](lib/collection.js) | [unit tests](test/collection.js) | [issues](https://github.com/jonathas/handlebars-helpers/issues?utf8=%E2%9C%93&q=is%3Aissue+is%3Aopen+collection+helpers))
177
-
178
- * **[isEmpty](#isEmpty)** ([code](lib/collection.js#L31) | [tests](test/collection.js#L14))
179
- * **[iterate](#iterate)** ([code](lib/collection.js#L59) | [tests](test/collection.js#L68))
180
-
181
- ### [comparison helpers](#comparison)
182
-
183
- Visit the: [code](lib/comparison.js) | [unit tests](test/comparison.js) | [issues](https://github.com/jonathas/handlebars-helpers/issues?utf8=%E2%9C%93&q=is%3Aissue+is%3Aopen+comparison+helpers))
184
-
185
- * **[and](#and)** ([code](lib/comparison.js#L27) | [tests](test/comparison.js#L10))
186
- * **[compare](#compare)** ([code](lib/comparison.js#L57) | [tests](test/comparison.js#L41))
187
- * **[contains](#contains)** ([code](lib/comparison.js#L124) | [tests](test/comparison.js#L167))
188
- * **[default](#default)** ([code](lib/comparison.js#L143) | [tests](test/comparison.js#L204))
189
- * **[eq](#eq)** ([code](lib/comparison.js#L165) | [tests](test/comparison.js#L351))
190
- * **[gt](#gt)** ([code](lib/comparison.js#L188) | [tests](test/comparison.js#L214))
191
- * **[gte](#gte)** ([code](lib/comparison.js#L212) | [tests](test/comparison.js#L245))
192
- * **[has](#has)** ([code](lib/comparison.js#L232) | [tests](test/comparison.js#L260))
193
- * **[isFalsey](#isFalsey)** ([code](lib/comparison.js#L274) | [tests](test/comparison.js#L327))
194
- * **[isTruthy](#isTruthy)** ([code](lib/comparison.js#L289) | [tests](test/comparison.js#L339))
195
- * **[ifEven](#ifEven)** ([code](lib/comparison.js#L310) | [tests](test/comparison.js#L368))
196
- * **[ifNth](#ifNth)** ([code](lib/comparison.js#L327) | [tests](test/comparison.js#L380))
197
- * **[ifOdd](#ifOdd)** ([code](lib/comparison.js#L350) | [tests](test/comparison.js#L403))
198
- * **[is](#is)** ([code](lib/comparison.js#L274) | [tests](test/comparison.js#L327))
199
- * **[isnt](#isnt)** ([code](lib/comparison.js#L389) | [tests](test/comparison.js#L432))
200
- * **[lt](#lt)** ([code](lib/comparison.js#L411) | [tests](test/comparison.js#L449))
201
- * **[lte](#lte)** ([code](lib/comparison.js#L435) | [tests](test/comparison.js#L476))
202
- * **[neither](#neither)** ([code](lib/comparison.js#L456) | [tests](test/comparison.js#L511))
203
- * **[not](#not)** ([code](lib/comparison.js#L470) | [tests](test/comparison.js#L624))
204
- * **[or](#or)** ([code](lib/comparison.js#L492) | [tests](test/comparison.js#L523))
205
- * **[unlessEq](#unlessEq)** ([code](lib/comparison.js#L518) | [tests](test/comparison.js#L556))
206
- * **[unlessGt](#unlessGt)** ([code](lib/comparison.js#L538) | [tests](test/comparison.js#L567))
207
- * **[unlessLt](#unlessLt)** ([code](lib/comparison.js#L558) | [tests](test/comparison.js#L578))
208
- * **[unlessGteq](#unlessGteq)** ([code](lib/comparison.js#L578) | [tests](test/comparison.js#L589))
209
- * **[unlessLteq](#unlessLteq)** ([code](lib/comparison.js#L598) | [tests](test/comparison.js#L604))
210
-
211
- ### [date helpers](#date)
212
-
213
- Visit the: [code](lib/date.js) | [unit tests](test/date.js) | [issues](https://github.com/jonathas/handlebars-helpers/issues?utf8=%E2%9C%93&q=is%3Aissue+is%3Aopen+date+helpers))
214
-
215
- * **[year](#year)** ([code](lib/date.js#L15) | [no tests])
216
- * **[date](#date)** ([code](lib/date.js#Lundefined) | [no tests])
217
- * **[moment](#moment)** ([code](lib/date.js#L24) | [no tests])
218
-
219
- ### [fs helpers](#fs)
220
-
221
- Visit the: [code](lib/fs.js) | [unit tests](test/fs.js) | [issues](https://github.com/jonathas/handlebars-helpers/issues?utf8=%E2%9C%93&q=is%3Aissue+is%3Aopen+fs+helpers))
222
-
223
- * **[fileSize](#fileSize)** ([code](lib/fs.js#L14) | [no tests])
224
- * **[read](#read)** ([code](lib/fs.js#L29) | [tests](test/fs.js#L16))
225
- * **[readdir](#readdir)** ([code](lib/fs.js#L42) | [tests](test/fs.js#L23))
226
-
227
- ### [html helpers](#html)
228
-
229
- Visit the: [code](lib/html.js) | [unit tests](test/html.js) | [issues](https://github.com/jonathas/handlebars-helpers/issues?utf8=%E2%9C%93&q=is%3Aissue+is%3Aopen+html+helpers))
230
-
231
- * **[attr](#attr)** ([code](lib/html.js#L23) | [tests](test/html.js#L13))
232
- * **[css](#css)** ([code](lib/html.js#L45) | [tests](test/html.js#L21))
233
- * **[js](#js)** ([code](lib/html.js#L89) | [tests](test/html.js#L69))
234
- * **[sanitize](#sanitize)** ([code](lib/html.js#L121) | [tests](test/html.js#L98))
235
- * **[ul](#ul)** ([code](lib/html.js#L135) | [tests](test/html.js#L108))
236
- * **[ol](#ol)** ([code](lib/html.js#L154) | [tests](test/html.js#L115))
237
- * **[thumbnailImage](#thumbnailImage)** ([code](lib/html.js#L176) | [tests](test/html.js#L122))
238
-
239
- ### [i18n helpers](#i18n)
240
-
241
- Visit the: [code](lib/i18n.js) | [unit tests](test/i18n.js) | [issues](https://github.com/jonathas/handlebars-helpers/issues?utf8=%E2%9C%93&q=is%3Aissue+is%3Aopen+i18n+helpers))
242
-
243
- * **[i18n](#i18n)** ([code](lib/i18n.js#L18) | [tests](test/i18n.js#L11))
244
-
245
- ### [inflection helpers](#inflection)
246
-
247
- Visit the: [code](lib/inflection.js) | [unit tests](test/inflection.js) | [issues](https://github.com/jonathas/handlebars-helpers/issues?utf8=%E2%9C%93&q=is%3Aissue+is%3Aopen+inflection+helpers))
248
-
249
- * **[inflect](#inflect)** ([code](lib/inflection.js#L30) | [tests](test/inflection.js#L9))
250
- * **[ordinalize](#ordinalize)** ([code](lib/inflection.js#L58) | [tests](test/inflection.js#L22))
251
-
252
- ### [logging helpers](#logging)
253
-
254
- Visit the: [code](lib/logging.js) | [unit tests](test/logging.js) | [issues](https://github.com/jonathas/handlebars-helpers/issues?utf8=%E2%9C%93&q=is%3Aissue+is%3Aopen+logging+helpers))
255
-
256
- * **[log](#log)** ([code](lib/logging.js#Lundefined) | [no tests])
257
- * **[ok](#ok)** ([code](lib/logging.js#Lundefined) | [no tests])
258
- * **[success](#success)** ([code](lib/logging.js#Lundefined) | [no tests])
259
- * **[info](#info)** ([code](lib/logging.js#Lundefined) | [no tests])
260
- * **[warning](#warning)** ([code](lib/logging.js#Lundefined) | [no tests])
261
- * **[warn](#warn)** ([code](lib/logging.js#Lundefined) | [no tests])
262
- * **[error](#error)** ([code](lib/logging.js#Lundefined) | [no tests])
263
- * **[danger](#danger)** ([code](lib/logging.js#Lundefined) | [no tests])
264
- * **[bold](#bold)** ([code](lib/logging.js#Lundefined) | [no tests])
265
- * **[_debug](#_debug)** ([code](lib/logging.js#Lundefined) | [no tests])
266
- * **[_inspect](#_inspect)** ([code](lib/logging.js#Lundefined) | [no tests])
267
-
268
- ### [markdown helpers](#markdown)
269
-
270
- * **[markdown](#markdown)** ([code](lib/markdown.js#Lundefined) | [tests](test/markdown.js#L10))
271
- * **[md](#md)** ([code](lib/markdown.js#L55) | [tests](test/markdown.js#L18))
272
-
273
- ### [match helpers](#match)
274
-
275
- Visit the: [code](lib/match.js) | [unit tests](test/match.js) | [issues](https://github.com/jonathas/handlebars-helpers/issues?utf8=%E2%9C%93&q=is%3Aissue+is%3Aopen+match+helpers))
276
-
277
- * **[match](#match)** ([code](lib/match.js#L23) | [tests](test/match.js#L13))
278
- * **[isMatch](#isMatch)** ([code](lib/match.js#L47) | [tests](test/match.js#L61))
279
- * **[mm](#mm)** ([code](lib/match.js#L56) | [tests](test/match.js#L67))
280
-
281
- ### [math helpers](#math)
282
-
283
- Visit the: [code](lib/math.js) | [unit tests](test/math.js) | [issues](https://github.com/jonathas/handlebars-helpers/issues?utf8=%E2%9C%93&q=is%3Aissue+is%3Aopen+math+helpers))
284
-
285
- * **[abs](#abs)** ([code](lib/math.js#L15) | [test](test/math.js#L149))
286
- * **[add](#add)** ([code](lib/math.js#L31) | [tests](test/math.js#L10))
287
- * **[avg](#avg)** ([code](lib/math.js#L54) | [tests](test/math.js#L25))
288
- * **[ceil](#ceil)** ([code](lib/math.js#L69) | [tests](test/math.js#L29))
289
- * **[divide](#divide)** ([code](lib/math.js#L84) | [tests](test/math.js#L36))
290
- * **[floor](#floor)** ([code](lib/math.js#L102) | [tests](test/math.js#L43))
291
- * **[minus](#minus)** ([code](lib/math.js#L118) | [tests](test/math.js#L169))
292
- * **[modulo](#modulo)** ([code](lib/math.js#L137) | [tests](test/math.js#L191))
293
- * **[multiply](#multiply)** ([code](lib/math.js#L157) | [tests](test/math.js#L50))
294
- * **[plus](#plus)** ([code](lib/math.js#L175) | [tests](test/math.js#L231))
295
- * **[random](#random)** ([code](lib/math.js#L194) | [tests](test/math.js#L102))
296
- * **[remainder](#remainder)** ([code](lib/math.js#L212) | [tests](test/math.js#L57))
297
- * **[round](#round)** ([code](lib/math.js#L224) | [tests](test/math.js#L69))
298
- * **[subtract](#subtract)** ([code](lib/math.js#L241) | [tests](test/math.js#L76))
299
- * **[sum](#sum)** ([code](lib/math.js#L263) | [tests](test/math.js#L83))
300
- * **[times](#times)** ([code](lib/math.js#L286) | [tests](test/math.js#L299))
301
-
302
- ### [misc helpers](#misc)
303
-
304
- Visit the: [code](lib/misc.js) | [unit tests](test/misc.js) | [issues](https://github.com/jonathas/handlebars-helpers/issues?utf8=%E2%9C%93&q=is%3Aissue+is%3Aopen+misc+helpers))
305
-
306
- * **[frame](#frame)** ([code](lib/misc.js#L11) | [tests](test/misc.js#L1))
307
- * **[option](#option)** ([code](lib/misc.js#L26) | [tests](test/misc.js#L20))
308
- * **[noop](#noop)** ([code](lib/misc.js#L39) | [tests](test/misc.js#L13))
309
- * **[typeOf](#typeOf)** ([code](lib/misc.js#L59) | [tests](test/misc.js#L38))
310
- * **[withHash](#withHash)** ([code](lib/misc.js#L71) | [tests](test/misc.js#L38))
311
-
312
- ### [number helpers](#number)
313
-
314
- Visit the: [code](lib/number.js) | [unit tests](test/number.js) | [issues](https://github.com/jonathas/handlebars-helpers/issues?utf8=%E2%9C%93&q=is%3Aissue+is%3Aopen+number+helpers))
315
-
316
- * **[bytes](#bytes)** ([code](lib/number.js#L24) | [tests](test/number.js#L10))
317
- * **[addCommas](#addCommas)** ([code](lib/number.js#L61) | [tests](test/number.js#L84))
318
- * **[phoneNumber](#phoneNumber)** ([code](lib/number.js#L74) | [tests](test/number.js#L30))
319
- * **[toAbbr](#toAbbr)** ([code](lib/number.js#L92) | [tests](test/number.js#L91))
320
- * **[toExponential](#toExponential)** ([code](lib/number.js#L130) | [tests](test/number.js#L59))
321
- * **[toFixed](#toFixed)** ([code](lib/number.js#L153) | [tests](test/number.js#L37))
322
- * **[toFloat](#toFloat)** ([code](lib/number.js#L169) | [tests](test/number.js#L77))
323
- * **[toInt](#toInt)** ([code](lib/number.js#L179) | [tests](test/number.js#L70))
324
- * **[toPrecision](#toPrecision)** ([code](lib/number.js#L196) | [tests](test/number.js#L48))
325
-
326
- ### [object helpers](#object)
327
-
328
- Visit the: [code](lib/object.js) | [unit tests](test/object.js) | [issues](https://github.com/jonathas/handlebars-helpers/issues?utf8=%E2%9C%93&q=is%3Aissue+is%3Aopen+object+helpers))
329
-
330
- * **[extend](#extend)** ([code](lib/object.js#L18) | [tests](test/object.js#L15))
331
- * **[forIn](#forIn)** ([code](lib/object.js#L55) | [tests](test/object.js#L33))
332
- * **[forOwn](#forOwn)** ([code](lib/object.js#L81) | [tests](test/object.js#L50))
333
- * **[toPath](#toPath)** ([code](lib/object.js#L106) | [tests](test/object.js#L87))
334
- * **[get](#get)** ([code](lib/object.js#L128) | [tests](test/object.js#L77))
335
- * **[getObject](#getObject)** ([code](lib/object.js#L149) | [tests](test/object.js#L77))
336
- * **[hasOwn](#hasOwn)** ([code](lib/object.js#L167) | [tests](test/object.js#L126))
337
- * **[isObject](#isObject)** ([code](lib/object.js#L183) | [tests](test/object.js#L144))
338
- * **[JSONparse](#JSONparse)** ([code](lib/object.js#L201) | [tests](test/object.js#L164))
339
- * **[JSONstringify](#JSONstringify)** ([code](lib/object.js#L218) | [no tests])
340
- * **[merge](#merge)** ([code](lib/object.js#L235) | [tests](test/object.js#L156))
341
- * **[parseJSON](#parseJSON)** ([code](lib/object.js#L254) | [no tests])
342
- * **[pick](#pick)** ([code](lib/object.js#L267) | [tests](test/object.js#L171))
343
- * **[stringify](#stringify)** ([code](lib/object.js#L290) | [tests](test/object.js#L199))
344
-
345
- ### [path helpers](#path)
346
-
347
- Visit the: [code](lib/path.js) | [unit tests](test/path.js) | [issues](https://github.com/jonathas/handlebars-helpers/issues?utf8=%E2%9C%93&q=is%3Aissue+is%3Aopen+path+helpers))
348
-
349
- * **[absolute](#absolute)** ([code](lib/path.js#L20) | [tests](test/path.js#L13))
350
- * **[dirname](#dirname)** ([code](lib/path.js#L40) | [tests](test/path.js#L25))
351
- * **[relative](#relative)** ([code](lib/path.js#L59) | [tests](test/path.js#L32))
352
- * **[basename](#basename)** ([code](lib/path.js#L81) | [tests](test/path.js#L47))
353
- * **[stem](#stem)** ([code](lib/path.js#L100) | [tests](test/path.js#L58))
354
- * **[extname](#extname)** ([code](lib/path.js#L119) | [tests](test/path.js#L69))
355
- * **[resolve](#resolve)** ([code](lib/path.js#L138) | [tests](test/path.js#L145))
356
- * **[segments](#segments)** ([code](lib/path.js#L166) | [tests](test/path.js#L80))
357
-
358
- ### [regex helpers](#regex)
359
-
360
- Visit the: [code](lib/regex.js) | [unit tests](test/regex.js) | [issues](https://github.com/jonathas/handlebars-helpers/issues?utf8=%E2%9C%93&q=is%3Aissue+is%3Aopen+regex+helpers))
361
-
362
- * **[toRegex](#toRegex)** ([code](lib/regex.js#L19) | [tests](test/regex.js#10))
363
- * **[test](#test)** ([code](lib/regex.js#L42) | [tests](test/regex.js#15))
364
-
365
- ### [string helpers](#string)
366
-
367
- Visit the: [code](lib/string.js) | [unit tests](test/string.js) | [issues](https://github.com/jonathas/handlebars-helpers/issues?utf8=%E2%9C%93&q=is%3Aissue+is%3Aopen+string+helpers))
368
-
369
- * **[append](#append)** ([code](lib/string.js#L22) | [tests](test/string.js#L9))
370
- * **[camelcase](#camelcase)** ([code](lib/string.js#L41) | [tests](test/string.js#L10))
371
- * **[capitalize](#capitalize)** ([code](lib/string.js#L60) | [tests](test/string.js#L25))
372
- * **[capitalizeAll](#capitalizeAll)** ([code](lib/string.js#L77) | [tests](test/string.js#L36))
373
- * **[center](#center)** ([code](lib/string.js#L95) | [tests](test/string.js#L47))
374
- * **[chop](#chop)** ([code](lib/string.js#L125) | [tests](test/string.js#L58))
375
- * **[dashcase](#dashcase)** ([code](lib/string.js#L143) | [tests](test/string.js#L73))
376
- * **[dotcase](#dotcase)** ([code](lib/string.js#L162) | [tests](test/string.js#L88))
377
- * **[downcase](#downcase)** ([code](lib/string.js#L182) | [tests](test/string.js#L391))
378
- * **[ellipsis](#ellipsis)** ([code](lib/string.js#L202) | [tests](test/string.js#L103))
379
- * **[hyphenate](#hyphenate)** ([code](lib/string.js#L223) | [tests](test/string.js#L118))
380
- * **[isString](#isString)** ([code](lib/string.js#L240) | [tests](test/string.js#L129))
381
- * **[lowercase](#lowercase)** ([code](lib/string.js#L256) | [tests](test/string.js#L151))
382
- * **[occurrences](#occurrences)** ([code](lib/string.js#L278) | [tests](test/string.js#L162))
383
- * **[pascalcase](#pascalcase)** ([code](lib/string.js#L303) | [tests](test/string.js#L173))
384
- * **[pathcase](#pathcase)** ([code](lib/string.js#L323) | [tests](test/string.js#L188))
385
- * **[plusify](#plusify)** ([code](lib/string.js#L343) | [tests](test/string.js#L203))
386
- * **[prepend](#prepend)** ([code](lib/string.js#L363) | [tests](test/string.js#L409))
387
- * **[raw](#raw)** ([code](lib/string.js#L385) | [tests](test/string.js#L465))
388
- * **[remove](#remove)** ([code](lib/string.js#L413) | [tests](test/string.js#L416)
389
- * **[removeFirst](#removeFirst)** ([code](lib/string.js#L432) | [tests](test/string.js#L422))
390
- * **[replace](#replace)** ([code](lib/string.js#L452) | [tests](test/string.js#L222))
391
- * **[replaceFirst](#replaceFirst)** ([code](lib/string.js#L473) | [tests](test/string.js#L428))
392
- * **[reverse](#reverse)** ([code](lib/string.js#L492) | [tests](test/string.js#L241))
393
- * **[sentence](#sentence)** ([code](lib/string.js#L509) | [tests](test/string.js#L252))
394
- * **[snakecase](#snakecase)** ([code](lib/string.js#L528) | [tests](test/string.js#L263))
395
- * **[split](#split)** ([code](lib/string.js#L547) | [tests](test/string.js#L278))
396
- * **[startsWith](#startsWith)** ([code](lib/string.js#L572) | [tests](test/string.js#L293))
397
- * **[titleize](#titleize)** ([code](lib/string.js#L596) | [tests](test/string.js#L312))
398
- * **[trim](#trim)** ([code](lib/string.js#L623) | [tests](test/string.js#L323))
399
- * **[trimLeft](#trimLeft)** ([code](lib/string.js#L639) | [tests](test/string.js#L436))
400
- * **[trimRight](#trimRight)** ([code](lib/string.js#L657) | [tests](test/string.js#L441))
401
- * **[truncate](#truncate)** ([code](lib/string.js#L680) | [tests](test/string.js#L338))
402
- * **[truncateWords](#truncateWords)** ([code](lib/string.js#L712) | [tests](test/string.js#L447)))
403
- * **[upcase](#upcase)** ([code](lib/string.js#L742) | [tests](test/string.js#458))
404
- * **[uppercase](#uppercase)** ([code](lib/string.js#L763) | [tests](test/string.js#L362))
405
-
406
- ### [url helpers](#url)
407
-
408
- Visit the: [code](lib/url.js) | [unit tests](test/url.js) | [issues](https://github.com/jonathas/handlebars-helpers/issues?utf8=%E2%9C%93&q=is%3Aissue+is%3Aopen+url+helpers))
409
-
410
- * **[encodeURI](#encodeURI)** ([code](lib/url.js#L19) | [tests](test/url.js#L31))
411
- * **[escape](#escape)** ([code](lib/url.js#L34) | [tests](test/url.js#L81))
412
- * **[decodeURI](#decodeURI)** ([code](lib/url.js#L48) | [tests](test/url.js#L38))
413
- * **[url_encode](#url_encode)** ([code](lib/url.js#L59) | [tests](test/url.js#L89))
414
- * **[url_decode](#url_decode)** ([code](lib/url.js#L68) | [tests](test/url.js#L93))
415
- * **[urlResolve](#urlResolve)** ([code](lib/url.js#L82) | [tests](test/url.js#L11))
416
- * **[urlParse](#urlParse)** ([code](lib/url.js#L94) | [tests](test/url.js#L45))
417
- * **[stripQuerystring](#stripQuerystring)** ([code](lib/url.js#L106) | [tests](test/url.js#L24))
418
- * **[stripProtocol](#stripProtocol)** ([code](lib/url.js#L126) | [tests](test/url.js#L53))
419
-
420
- ***
421
-
422
- ## array
423
-
424
- ### [{{after}}](lib/array.js#L22)
425
-
426
- Returns all of the items in an array after the specified index. Opposite of [before](#before).
427
-
428
- **Params**
429
-
430
- * `array` **{Array}**: Collection
431
- * `n` **{Number}**: Starting index (number of items to exclude)
432
- * `returns` **{Array}**: Array exluding `n` items.
433
-
434
- **Example**
435
-
436
- ```html
437
- <!-- array: ['a', 'b', 'c'] -->
438
- {{after array 1}}
439
- <!-- results in: '["c"]' -->
440
- ```
441
-
442
- ### [{{arrayify}}](lib/array.js#L39)
443
-
444
- Cast the given `value` to an array.
445
-
446
- **Params**
447
-
448
- * `value` **{any}**
449
- * `returns` **{Array}**
450
-
451
- **Example**
452
-
453
- ```html
454
- {{arrayify "foo"}}
455
- <!-- results in: [ "foo" ] -->
456
- ```
457
-
458
- ### [{{before}}](lib/array.js#L58)
459
-
460
- Return all of the items in the collection before the specified count. Opposite of [after](#after).
461
-
462
- **Params**
463
-
464
- * `array` **{Array}**
465
- * `n` **{Number}**
466
- * `returns` **{Array}**: Array excluding items after the given number.
467
-
468
- **Example**
469
-
470
- ```html
471
- <!-- array: ['a', 'b', 'c'] -->
472
- {{before array 2}}
473
- <!-- results in: '["a", "b"]' -->
474
- ```
475
-
476
- ### [{{eachIndex}}](lib/array.js#L77)
477
-
478
- **Params**
479
-
480
- * `array` **{Array}**
481
- * `options` **{Object}**
482
- * `returns` **{String}**
483
-
484
- **Example**
485
-
486
- ```html
487
- <!-- array: ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h'] -->
488
- {{#eachIndex array}}
489
- {{item}} is {{index}}
490
- {{/eachIndex}}
491
- ```
492
-
493
- ### [{{filter}}](lib/array.js#L102)
494
-
495
- Block helper that filters the given array and renders the block for values that evaluate to `true`, otherwise the inverse block is returned.
496
-
497
- **Params**
498
-
499
- * `array` **{Array}**
500
- * `value` **{any}**
501
- * `options` **{Object}**
502
- * `returns` **{String}**
503
-
504
- **Example**
505
-
506
- ```html
507
- <!-- array: ['a', 'b', 'c'] -->
508
- {{#filter array "foo"}}AAA{{else}}BBB{{/filter}}
509
- <!-- results in: 'BBB' -->
510
- ```
511
-
512
- ### [{{first}}](lib/array.js#L142)
513
-
514
- Returns the first item, or first `n` items of an array.
515
-
516
- **Params**
517
-
518
- * `array` **{Array}**
519
- * `n` **{Number}**: Number of items to return, starting at `0`.
520
- * `returns` **{Array}**
521
-
522
- **Example**
523
-
524
- ```html
525
- {{first "['a', 'b', 'c', 'd', 'e']" 2}}
526
- <!-- results in: '["a", "b"]' -->
527
- ```
528
-
529
- ### [{{forEach}}](lib/array.js#L184)
530
-
531
- Iterates over each item in an array and exposes the current item in the array as context to the inner block. In addition to the current array item, the helper exposes the following variables to the inner block:
532
-
533
- * `index`
534
- * `total`
535
- * `isFirst`
536
- * `isLast`
537
- Also, `@index` is exposed as a private variable, and additional
538
- private variables may be defined as hash arguments.
539
-
540
- **Params**
541
-
542
- * `array` **{Array}**
543
- * `returns` **{String}**
544
-
545
- **Example**
546
-
547
- ```html
548
- <!-- accounts = [
549
- {'name': 'John', 'email': 'john@example.com'},
550
- {'name': 'Malcolm', 'email': 'malcolm@example.com'},
551
- {'name': 'David', 'email': 'david@example.com'}
552
- ] -->
553
-
554
- {{#forEach accounts}}
555
- <a href="mailto:{{ email }}" title="Send an email to {{ name }}">
556
- {{ name }}
557
- </a>{{#unless isLast}}, {{/unless}}
558
- {{/forEach}}
559
- ```
560
-
561
- ### [{{inArray}}](lib/array.js#L224)
562
-
563
- Block helper that renders the block if an array has the given `value`. Optionally specify an inverse block to render when the array does not have the given value.
564
-
565
- **Params**
566
-
567
- * `array` **{Array}**
568
- * `value` **{any}**
569
- * `options` **{Object}**
570
- * `returns` **{String}**
571
-
572
- **Example**
573
-
574
- ```html
575
- <!-- array: ['a', 'b', 'c'] -->
576
- {{#inArray array "d"}}
577
- foo
578
- {{else}}
579
- bar
580
- {{/inArray}}
581
- <!-- results in: 'bar' -->
582
- ```
583
-
584
- ### [{{isArray}}](lib/array.js#L244)
585
-
586
- Returns true if `value` is an es5 array.
587
-
588
- **Params**
589
-
590
- * `value` **{any}**: The value to test.
591
- * `returns` **{Boolean}**
592
-
593
- **Example**
594
-
595
- ```html
596
- {{isArray "abc"}}
597
- <!-- results in: false -->
598
-
599
- <!-- array: [1, 2, 3] -->
600
- {{isArray array}}
601
- <!-- results in: true -->
602
- ```
603
-
604
- ### [{{itemAt}}](lib/array.js#L263)
605
-
606
- Returns the item from `array` at index `idx`.
607
-
608
- **Params**
609
-
610
- * `array` **{Array}**
611
- * `idx` **{Number}**
612
- * `returns` **{any}** `value`
613
-
614
- **Example**
615
-
616
- ```html
617
- <!-- array: ['a', 'b', 'c'] -->
618
- {{itemAt array 1}}
619
- <!-- results in: 'b' -->
620
- ```
621
-
622
- ### [{{join}}](lib/array.js#L294)
623
-
624
- Join all elements of array into a string, optionally using a given separator.
625
-
626
- **Params**
627
-
628
- * `array` **{Array}**
629
- * `separator` **{String}**: The separator to use. Defaults to `,`.
630
- * `returns` **{String}**
631
-
632
- **Example**
633
-
634
- ```html
635
- <!-- array: ['a', 'b', 'c'] -->
636
- {{join array}}
637
- <!-- results in: 'a, b, c' -->
638
-
639
- {{join array '-'}}
640
- <!-- results in: 'a-b-c' -->
641
- ```
642
- ### [{{equalsLength}}](lib/array.js#L313)
643
-
644
- Returns true if the the length of the given `value` is equal
645
- to the given `length`. Can be used as a block or inline helper.
646
-
647
- **Params**
648
-
649
- * `value` **{Array|String}**
650
- * `length` **{Number}**
651
- * `options` **{Object}**
652
- * `returns` **{String}**
653
-
654
- ### [{{last}}](lib/array.js#L349)
655
-
656
- Returns the last item, or last `n` items of an array or string. Opposite of [first](#first).
657
-
658
- **Params**
659
-
660
- * `value` **{Array|String}**: Array or string.
661
- * `n` **{Number}**: Number of items to return from the end of the array.
662
- * `returns` **{Array}**
663
-
664
- **Example**
665
-
666
- ```html
667
- <!-- var value = ['a', 'b', 'c', 'd', 'e'] -->
668
-
669
- {{last value}}
670
- <!-- results in: ['e'] -->
671
-
672
- {{last value 2}}
673
- <!-- results in: ['d', 'e'] -->
674
-
675
- {{last value 3}}
676
- <!-- results in: ['c', 'd', 'e'] -->
677
- ```
678
-
679
- ### [{{length}}](lib/array.js#L379)
680
-
681
- Returns the length of the given string or array.
682
-
683
- **Params**
684
-
685
- * `value` **{Array|Object|String}**
686
- * `returns` **{Number}**: The length of the value.
687
-
688
- **Example**
689
-
690
- ```html
691
- {{length '["a", "b", "c"]'}}
692
- <!-- results in: 3 -->
693
-
694
- <!-- results in: myArray = ['a', 'b', 'c', 'd', 'e']; -->
695
- {{length myArray}}
696
- <!-- results in: 5 -->
697
-
698
- <!-- results in: myObject = {'a': 'a', 'b': 'b'}; -->
699
- {{length myObject}}
700
- <!-- results in: 2 -->
701
- ```
702
-
703
- ### [{{lengthEqual}}](lib/array.js#L395)
704
-
705
- Alias for [equalsLength](#equalsLength)
706
-
707
- ### [{{map}}](lib/array.js#L414)
708
-
709
- Returns a new array, created by calling `function` on each element of the given `array`. For example,
710
-
711
- **Params**
712
-
713
- * `array` **{Array}**
714
- * `fn` **{Function}**
715
- * `returns` **{String}**
716
-
717
- **Example**
718
-
719
- ```html
720
- <!-- array: ['a', 'b', 'c'], and "double" is a
721
- fictitious function that duplicates letters -->
722
- {{map array double}}
723
- <!-- results in: '["aa", "bb", "cc"]' -->
724
- ```
725
-
726
- ### [{{pluck}}](lib/array.js#L445)
727
-
728
- Map over the given object or array or objects and create an array of values from the given `prop`. Dot-notation may be used (as a string) to get nested properties.
729
-
730
- **Params**
731
-
732
- * `collection` **{Array|Object}**
733
- * `prop` **{Function}**
734
- * `returns` **{String}**
735
-
736
- **Example**
737
-
738
- ```html
739
- // {{pluck items "data.title"}}
740
- <!-- results in: '["aa", "bb", "cc"]' -->
741
- ```
742
-
743
- ### [{{reverse}}](lib/array.js#L473)
744
-
745
- Reverse the elements in an array, or the characters in a string.
746
-
747
- **Params**
748
-
749
- * `value` **{Array|String}**
750
- * `returns` **{Array|String}**: Returns the reversed string or array.
751
-
752
- **Example**
753
-
754
- ```html
755
- <!-- value: 'abcd' -->
756
- {{reverse value}}
757
- <!-- results in: 'dcba' -->
758
- <!-- value: ['a', 'b', 'c', 'd'] -->
759
- {{reverse value}}
760
- <!-- results in: ['d', 'c', 'b', 'a'] -->
761
- ```
762
-
763
- ### [{{some}}](lib/array.js#L504)
764
-
765
- Block helper that returns the block if the callback returns true for some value in the given array.
766
-
767
- **Params**
768
-
769
- * `array` **{Array}**
770
- * `iter` **{Function}**: Iteratee
771
- * **{Options}**: Handlebars provided options object
772
- * `returns` **{String}**
773
-
774
- **Example**
775
-
776
- ```html
777
- <!-- array: [1, 'b', 3] -->
778
- {{#some array isString}}
779
- Render me if the array has a string.
780
- {{else}}
781
- Render me if it doesn't.
782
- {{/some}}
783
- <!-- results in: 'Render me if the array has a string.' -->
784
- ```
785
-
786
- ### [{{sort}}](lib/array.js#L532)
787
-
788
- Sort the given `array`. If an array of objects is passed, you may optionally pass a `key` to sort on as the second argument. You may alternatively pass a sorting function as the second argument.
789
-
790
- **Params**
791
-
792
- * `array` **{Array}**: the array to sort.
793
- * `key` **{String|Function}**: The object key to sort by, or sorting function.
794
-
795
- **Example**
796
-
797
- ```html
798
- <!-- array: ['b', 'a', 'c'] -->
799
- {{sort array}}
800
- <!-- results in: '["a", "b", "c"]' -->
801
- ```
802
-
803
- ### [{{sortBy}}](lib/array.js#L557)
804
-
805
- Sort an `array`. If an array of objects is passed, you may optionally pass a `key` to sort on as the second argument. You may alternatively pass a sorting function as the second argument.
806
-
807
- **Params**
808
-
809
- * `array` **{Array}**: the array to sort.
810
- * `props` **{String|Function}**: One or more properties to sort by, or sorting functions to use.
811
-
812
- **Example**
813
-
814
- ```html
815
- <!-- array: [{a: 'zzz'}, {a: 'aaa'}] -->
816
- {{sortBy array "a"}}
817
- <!-- results in: '[{"a":"aaa"}, {"a":"zzz"}]' -->
818
- ```
819
-
820
- ### [{{withAfter}}](lib/array.js#L588)
821
-
822
- Use the items in the array _after_ the specified index as context inside a block. Opposite of [withBefore](#withBefore).
823
-
824
- **Params**
825
-
826
- * `array` **{Array}**
827
- * `idx` **{Number}**
828
- * `options` **{Object}**
829
- * `returns` **{Array}**
830
-
831
- **Example**
832
-
833
- ```html
834
- <!-- array: ['a', 'b', 'c', 'd', 'e'] -->
835
- {{#withAfter array 3}}
836
- {{this}}
837
- {{/withAfter}}
838
- <!-- results in: "de" -->
839
- ```
840
-
841
- ### [{{withBefore}}](lib/array.js#L618)
842
-
843
- Use the items in the array _before_ the specified index as context inside a block. Opposite of [withAfter](#withAfter).
844
-
845
- **Params**
846
-
847
- * `array` **{Array}**
848
- * `idx` **{Number}**
849
- * `options` **{Object}**
850
- * `returns` **{Array}**
851
-
852
- **Example**
853
-
854
- ```html
855
- <!-- array: ['a', 'b', 'c', 'd', 'e'] -->
856
- {{#withBefore array 3}}
857
- {{this}}
858
- {{/withBefore}}
859
- <!-- results in: 'ab' -->
860
- ```
861
-
862
- ### [{{withFirst}}](lib/array.js#L648)
863
-
864
- Use the first item in a collection inside a handlebars block expression. Opposite of [withLast](#withLast).
865
-
866
- **Params**
867
-
868
- * `array` **{Array}**
869
- * `idx` **{Number}**
870
- * `options` **{Object}**
871
- * `returns` **{String}**
872
-
873
- **Example**
874
-
875
- ```html
876
- <!-- array: ['a', 'b', 'c'] -->
877
- {{#withFirst array}}
878
- {{this}}
879
- {{/withFirst}}
880
- <!-- results in: 'a' -->
881
- ```
882
-
883
- ### [{{withGroup}}](lib/array.js#L692)
884
-
885
- Block helper that groups array elements by given group `size`.
886
-
887
- **Params**
888
-
889
- * `array` **{Array}**: The array to iterate over
890
- * `size` **{Number}**: The desired length of each array "group"
891
- * `options` **{Object}**: Handlebars options
892
- * `returns` **{String}**
893
-
894
- **Example**
895
-
896
- ```html
897
- <!-- array: ['a','b','c','d','e','f','g','h'] -->
898
- {{#withGroup array 4}}
899
- {{#each this}}
900
- {{.}}
901
- {{each}}
902
- <br>
903
- {{/withGroup}}
904
- <!-- results in: -->
905
- <!-- 'a','b','c','d'<br> -->
906
- <!-- 'e','f','g','h'<br> -->
907
- ```
908
-
909
- ### [{{withLast}}](lib/array.js#L727)
910
-
911
- Use the last item or `n` items in an array as context inside a block. Opposite of [withFirst](#withFirst).
912
-
913
- **Params**
914
-
915
- * `array` **{Array}**
916
- * `idx` **{Number}**: The starting index.
917
- * `options` **{Object}**
918
- * `returns` **{String}**
919
-
920
- **Example**
921
-
922
- ```html
923
- <!-- array: ['a', 'b', 'c'] -->
924
- {{#withLast array}}
925
- {{this}}
926
- {{/withLast}}
927
- <!-- results in: 'c' -->
928
- ```
929
-
930
- ### [{{withSort}}](lib/array.js#L766)
931
-
932
- Block helper that sorts a collection and exposes the sorted collection as context inside the block.
933
-
934
- **Params**
935
-
936
- * `array` **{Array}**
937
- * `prop` **{String}**
938
- * `options` **{Object}**: Specify `reverse="true"` to reverse the array.
939
- * `returns` **{String}**
940
-
941
- **Example**
942
-
943
- ```html
944
- <!-- array: ['b', 'a', 'c'] -->
945
- {{#withSort array}}{{this}}{{/withSort}}
946
- <!-- results in: 'abc' -->
947
- ```
948
-
949
- ### [{{unique}}](lib/array.js#L816)
950
-
951
- Block helper that return an array with all duplicate values removed. Best used along with a [each](#each) helper.
952
-
953
- **Params**
954
-
955
- * `array` **{Array}**
956
- * `options` **{Object}**
957
- * `returns` **{Array}**
958
-
959
- **Example**
960
-
961
- ```html
962
- <!-- array: ['a', 'a', 'c', 'b', 'e', 'e'] -->
963
- {{#each (unique array)}}{{.}}{{/each}}
964
- <!-- results in: 'acbe' -->
965
- ```
966
-
967
- ### [{{embed}}](lib/code.js#L23)
968
-
969
- Embed code from an external file as preformatted text.
970
-
971
- **Params**
972
-
973
- * `filepath` **{String}**: filepath to the file to embed.
974
- * `language` **{String}**: Optionally specify the language to use for syntax highlighting.
975
- * `returns` **{String}**
976
-
977
- **Example**
978
-
979
- ```html
980
- {{embed 'path/to/file.js'}}
981
- <!-- optionally specify the language to use -->
982
- {{embed 'path/to/file.hbs' 'html')}}
983
- ```
984
-
985
- ### [{{gist}}](lib/code.js#L45)
986
-
987
- Embed a GitHub Gist using only the id of the Gist
988
-
989
- **Params**
990
-
991
- * `id` **{String}**
992
- * `returns` **{String}**
993
-
994
- **Example**
995
-
996
- ```html
997
- {{gist "12345"}}
998
- ```
999
-
1000
- ### [{{jsfiddle}}](lib/code.js#L60)
1001
-
1002
- Generate the HTML for a jsFiddle link with the given `params`
1003
-
1004
- **Params**
1005
-
1006
- * `params` **{Object}**
1007
- * `returns` **{String}**
1008
-
1009
- **Example**
1010
-
1011
- ```html
1012
- {{jsfiddle id="0dfk10ks" tabs="true"}}
1013
- ```
1014
-
1015
- ## collection
1016
-
1017
- ### [{{isEmpty}}](lib/collection.js#L31)
1018
-
1019
- Inline, subexpression, or block helper that returns true (or the block) if the given collection is empty, or false (or the inverse block, if supplied) if the colleciton is not empty.
1020
-
1021
- **Params**
1022
-
1023
- * `collection` **{Object}**
1024
- * `options` **{Object}**
1025
- * `returns` **{String}**
1026
-
1027
- **Example**
1028
-
1029
- ```html
1030
- <!-- array: [] -->
1031
- {{#isEmpty array}}AAA{{else}}BBB{{/isEmpty}}
1032
- <!-- results in: 'AAA' -->
1033
-
1034
- <!-- array: [] -->
1035
- {{isEmpty array}}
1036
- <!-- results in: true -->
1037
- ```
1038
-
1039
- ### [{{iterate}}](lib/collection.js#L59)
1040
-
1041
- Block helper that iterates over an array or object. If
1042
- an array is given, `.forEach` is called, or if an object
1043
- is given, `.forOwn` is called, otherwise the inverse block
1044
- is returned.
1045
-
1046
- **Params**
1047
-
1048
- * `collection` **{Object|Array}**: The collection to iterate over
1049
- * `options` **{Object}**
1050
- * `returns` **{String}**
1051
-
1052
- ## comparison
1053
-
1054
- ### [{{and}}](lib/comparison.js#L27)
1055
-
1056
- Helper that renders the block if **both** of the given values are truthy. If an inverse block is specified it will be rendered when falsy. Works as a block helper, inline helper or subexpression.
1057
-
1058
- **Params**
1059
-
1060
- * `a` **{any}**
1061
- * `b` **{any}**
1062
- * `options` **{Object}**: Handlebars provided options object
1063
- * `returns` **{String}**
1064
-
1065
- **Example**
1066
-
1067
- ```html
1068
- <!-- {great: true, magnificent: true} -->
1069
- {{#and great magnificent}}A{{else}}B{{/and}}
1070
- <!-- results in: 'A' -->
1071
- ```
1072
-
1073
- ### [{{compare}}](lib/comparison.js#L57)
1074
-
1075
- Render a block when a comparison of the first and third
1076
- arguments returns true. The second argument is
1077
- the [arithemetic operator](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Arithmetic_Operators) to use. You may also
1078
- optionally specify an inverse block to render when falsy.
1079
-
1080
- **Params**
1081
-
1082
- * `a` **{}**
1083
- * `operator` **{}**: The operator to use. Operators must be enclosed in quotes: `">"`, `"="`, `"<="`, and so on.
1084
- * `b` **{}**
1085
- * `options` **{Object}**: Handlebars provided options object
1086
- * `returns` **{String}**: Block, or if specified the inverse block is rendered if falsey.
1087
-
1088
- ### [{{contains}}](lib/comparison.js#L124)
1089
-
1090
- Block helper that renders the block if `collection` has the given `value`, using strict equality (`===`) for comparison, otherwise the inverse block is rendered (if specified). If a `startIndex` is specified and is negative, it is used as the offset from the end of the collection.
1091
-
1092
- **Params**
1093
-
1094
- * `collection` **{Array|Object|String}**: The collection to iterate over.
1095
- * `value` **{any}**: The value to check for.
1096
- * `[startIndex=0]` **{Number}**: Optionally define the starting index.
1097
- * `options` **{Object}**: Handlebars provided options object.
1098
-
1099
- **Example**
1100
-
1101
- ```html
1102
- <!-- array = ['a', 'b', 'c'] -->
1103
- {{#contains array "d"}}
1104
- This will not be rendered.
1105
- {{else}}
1106
- This will be rendered.
1107
- {{/contains}}
1108
- ```
1109
-
1110
- ### [`{{default}}`](lib/comparison.js#L143)
1111
-
1112
- Returns the first value that is not undefined, otherwise the `default` value is returned.
1113
-
1114
- **Params**
1115
-
1116
- * `value` **{any}**
1117
- * `defaultValue` **{any}**
1118
- * `returns` **{String}**
1119
-
1120
- ### [{{eq}}](lib/comparison.js#L165)
1121
-
1122
- Block helper that renders a block if `a` is **equal to** `b`.
1123
- If an inverse block is specified it will be rendered when falsy.
1124
- You may optionally use the `compare=""` hash argument for the
1125
- second value.
1126
-
1127
- **Params**
1128
-
1129
- * `a` **{String}**
1130
- * `b` **{String}**
1131
- * `options` **{Object}**: Handlebars provided options object
1132
- * `returns` **{String}**: Block, or inverse block if specified and falsey.
1133
-
1134
- ### [{{gt}}](lib/comparison.js#L188)
1135
-
1136
- Block helper that renders a block if `a` is **greater than** `b`.
1137
-
1138
- If an inverse block is specified it will be rendered when falsy.
1139
- You may optionally use the `compare=""` hash argument for the
1140
- second value.
1141
-
1142
- **Params**
1143
-
1144
- * `a` **{String}**
1145
- * `b` **{String}**
1146
- * `options` **{Object}**: Handlebars provided options object
1147
- * `returns` **{String}**: Block, or inverse block if specified and falsey.
1148
-
1149
- ### [{{gte}}](lib/comparison.js#L212)
1150
-
1151
- Block helper that renders a block if `a` is **greater than or equal to** `b`.
1152
-
1153
- If an inverse block is specified it will be rendered when falsy.
1154
- You may optionally use the `compare=""` hash argument for the
1155
- second value.
1156
-
1157
- **Params**
1158
-
1159
- * `a` **{String}**
1160
- * `b` **{String}**
1161
- * `options` **{Object}**: Handlebars provided options object
1162
- * `returns` **{String}**: Block, or inverse block if specified and falsey.
1163
-
1164
- ### [{{has}}](lib/comparison.js#L232)
1165
-
1166
- Block helper that renders a block if `value` has `pattern`.
1167
- If an inverse block is specified it will be rendered when falsy.
1168
-
1169
- **Params**
1170
-
1171
- * `val` **{any}**: The value to check.
1172
- * `pattern` **{any}**: The pattern to check for.
1173
- * `options` **{Object}**: Handlebars provided options object
1174
- * `returns` **{String}**
1175
-
1176
- ### [{{isFalsey}}](lib/comparison.js#L274)
1177
-
1178
- Returns true if the given `value` is falsey. Uses the [falsey](https://github.com/jonschlinkert/falsey)
1179
- library for comparisons. Please see that library for more information
1180
- or to report bugs with this helper.
1181
-
1182
- **Params**
1183
-
1184
- * `val` **{any}**
1185
- * `options` **{Options}**
1186
- * `returns` **{Boolean}**
1187
-
1188
- ### [{{isTruthy}}](lib/comparison.js#L289)
1189
-
1190
- Returns true if the given `value` is truthy. Uses the [falsey](https://github.com/jonschlinkert/falsey)
1191
- library for comparisons. Please see that library for more information
1192
- or to report bugs with this helper.
1193
-
1194
- **Params**
1195
-
1196
- * `val` **{any}**
1197
- * `options` **{Options}**
1198
- * `returns` **{Boolean}**
1199
-
1200
- ### [{{ifEven}}](lib/comparison.js#L310)
1201
-
1202
- Return true if the given value is an even number.
1203
-
1204
- **Params**
1205
-
1206
- * `number` **{Number}**
1207
- * `options` **{Object}**: Handlebars provided options object
1208
- * `returns` **{String}**: Block, or inverse block if specified and falsey.
1209
-
1210
- **Example**
1211
-
1212
- ```html
1213
- {{#ifEven value}}
1214
- render A
1215
- {{else}}
1216
- render B
1217
- {{/ifEven}}
1218
- ```
1219
-
1220
- ### [{{ifNth}}](lib/comparison.js#L327)
1221
-
1222
- Conditionally renders a block if the remainder is zero when
1223
- `a` operand is divided by `b`. If an inverse block is specified
1224
- it will be rendered when the remainder is **not zero**.
1225
-
1226
- **Params**
1227
-
1228
- * **{}**: {Number}
1229
- * **{}**: {Number}
1230
- * `options` **{Object}**: Handlebars provided options object
1231
- * `returns` **{String}**: Block, or inverse block if specified and falsey.
1232
-
1233
- ### [{{ifOdd}}](lib/comparison.js#L350)
1234
-
1235
- Block helper that renders a block if `value` is **an odd number**. If an inverse block is specified it will be rendered when falsy.
1236
-
1237
- **Params**
1238
-
1239
- * `value` **{Object}**
1240
- * `options` **{Object}**: Handlebars provided options object
1241
- * `returns` **{String}**: Block, or inverse block if specified and falsey.
1242
-
1243
- **Example**
1244
-
1245
- ```html
1246
- {{#ifOdd value}}
1247
- render A
1248
- {{else}}
1249
- render B
1250
- {{/ifOdd}}
1251
- ```
1252
-
1253
- ### [`{{is}}`](lib/comparison.js#L367)
1254
-
1255
- Block helper that renders a block if `a` is **equal to** `b`.
1256
- If an inverse block is specified it will be rendered when falsy.
1257
- Similar to [eq](#eq) but does not do strict equality.
1258
-
1259
- **Params**
1260
-
1261
- * `a` **{any}**
1262
- * `b` **{any}**
1263
- * `options` **{Object}**: Handlebars provided options object
1264
- * `returns` **{String}**
1265
-
1266
- ### [`{{isnt}}`](lib/comparison.js#L389)
1267
-
1268
- Block helper that renders a block if `a` is **not equal to** `b`.
1269
- If an inverse block is specified it will be rendered when falsy.
1270
- Similar to [unlessEq](#unlesseq) but does not use strict equality for
1271
- comparisons.
1272
-
1273
- **Params**
1274
-
1275
- * `a` **{String}**
1276
- * `b` **{String}**
1277
- * `options` **{Object}**: Handlebars provided options object
1278
- * `returns` **{String}**
1279
-
1280
- ### [`{{lt}}`](lib/comparison.js#L411)
1281
-
1282
- Block helper that renders a block if `a` is **less than** `b`.
1283
-
1284
- If an inverse block is specified it will be rendered when falsy.
1285
- You may optionally use the `compare=""` hash argument for the
1286
- second value.
1287
-
1288
- **Params**
1289
-
1290
- * `context` **{Object}**
1291
- * `options` **{Object}**: Handlebars provided options object
1292
- * `returns` **{String}**: Block, or inverse block if specified and falsey.
1293
-
1294
- ### [`{{lte}}`](lib/comparison.js#L435)
1295
-
1296
- Block helper that renders a block if `a` is **less than or equal to** `b`.
1297
-
1298
- If an inverse block is specified it will be rendered when falsy.
1299
- You may optionally use the `compare=""` hash argument for the
1300
- second value.
1301
-
1302
- **Params**
1303
-
1304
- * `a` **{Sring}**
1305
- * `b` **{Sring}**
1306
- * `options` **{Object}**: Handlebars provided options object
1307
- * `returns` **{String}**: Block, or inverse block if specified and falsey.
1308
-
1309
- ### [`{{neither}}`](lib/comparison.js#L456)
1310
-
1311
- Block helper that renders a block if **neither of** the given values
1312
- are truthy. If an inverse block is specified it will be rendered
1313
- when falsy.
1314
-
1315
- **Params**
1316
-
1317
- * `a` **{any}**
1318
- * `b` **{any}**
1319
- * `options` **{}**: Handlebars options object
1320
- * `returns` **{String}**: Block, or inverse block if specified and falsey.
1321
-
1322
- ### [`{{not}}`](lib/comparison.js#L470)
1323
-
1324
- Returns true if `val` is falsey. Works as a block or inline helper.
1325
-
1326
- **Params**
1327
-
1328
- * `val` **{String}**
1329
- * `options` **{Object}**: Handlebars provided options object
1330
- * `returns` **{String}**
1331
-
1332
- ### [`{{or}}`](lib/comparison.js#L492)
1333
-
1334
- Block helper that renders a block if **any of** the given values is truthy. If an inverse block is specified it will be rendered when falsy.
1335
-
1336
- **Params**
1337
-
1338
- * `args` **{any}**: Variable number of arguments
1339
- * `options` **{Object}**: Handlebars options object
1340
- * `returns` **{String}**: Block, or inverse block if specified and falsey.
1341
-
1342
- **Example**
1343
-
1344
- ```html
1345
- {{#or a b c}}
1346
- If any value is true this will be rendered.
1347
- {{/or}}
1348
- ```
1349
-
1350
- ### [{{unlessEq}}](lib/comparison.js#L518)
1351
-
1352
- Block helper that always renders the inverse block **unless `a` is
1353
- is equal to `b`**.
1354
-
1355
- **Params**
1356
-
1357
- * `a` **{String}**
1358
- * `b` **{String}**
1359
- * `options` **{Object}**: Handlebars provided options object
1360
- * `returns` **{String}**: Inverse block by default, or block if falsey.
1361
-
1362
- ### [{{unlessGt}}](lib/comparison.js#L538)
1363
-
1364
- Block helper that always renders the inverse block **unless `a` is
1365
- is greater than `b`**.
1366
-
1367
- **Params**
1368
-
1369
- * `a` **{Object}**: The default value
1370
- * `b` **{Object}**: The value to compare
1371
- * `options` **{Object}**: Handlebars provided options object
1372
- * `returns` **{String}**: Inverse block by default, or block if falsey.
1373
-
1374
- ### [{{unlessLt}}](lib/comparison.js#L558)
1375
-
1376
- Block helper that always renders the inverse block **unless `a` is
1377
- is less than `b`**.
1378
-
1379
- **Params**
1380
-
1381
- * `a` **{Object}**: The default value
1382
- * `b` **{Object}**: The value to compare
1383
- * `options` **{Object}**: Handlebars provided options object
1384
- * `returns` **{String}**: Block, or inverse block if specified and falsey.
1385
-
1386
- ### [{{unlessGteq}}](lib/comparison.js#L578)
1387
-
1388
- Block helper that always renders the inverse block **unless `a` is
1389
- is greater than or equal to `b`**.
1390
-
1391
- **Params**
1392
-
1393
- * `a` **{any}**
1394
- * `b` **{any}**
1395
- * `options` **{Object}**: Handlebars provided options object
1396
- * `returns` **{String}**: Block, or inverse block if specified and falsey.
1397
-
1398
- ### [{{unlessLteq}}](lib/comparison.js#L598)
1399
-
1400
- Block helper that always renders the inverse block **unless `a` is
1401
- is less than or equal to `b`**.
1402
-
1403
- **Params**
1404
-
1405
- * `a` **{any}**
1406
- * `b` **{any}**
1407
- * `options` **{Object}**: Handlebars provided options object
1408
- * `returns` **{String}**: Block, or inverse block if specified and falsey.
1409
-
1410
- ## date
1411
-
1412
- ### [{{year}}](lib/date.js#L15)
1413
-
1414
- Get the current year.
1415
-
1416
- **Example**
1417
-
1418
- ```html
1419
- {{year}}
1420
- <!-- 2017 -->
1421
- ```
1422
-
1423
- ### [{{moment}}](lib/date.js#L24)
1424
-
1425
- Use [moment](http://momentjs.com) as a helper. See [helper-date](https://github.com/helpers/helper-date) for more details.
1426
-
1427
- ## fs
1428
-
1429
- ### [{{read}}](lib/fs.js#L29)
1430
-
1431
- Read a file from the file system. This is useful in composing "include"-style helpers using sub-expressions.
1432
-
1433
- **Params**
1434
-
1435
- * `filepath` **{String}**
1436
- * `returns` **{String}**
1437
-
1438
- **Example**
1439
-
1440
- ```html
1441
- {{read "a/b/c.js"}}
1442
- {{someHelper (read "a/b/c.md")}}
1443
- ```
1444
-
1445
- ### [{{readdir}}](lib/fs.js#L42)
1446
-
1447
- Return an array of files from the given
1448
- directory.
1449
-
1450
- **Params**
1451
-
1452
- * `directory` **{String}**
1453
- * `returns` **{Array}**
1454
-
1455
- ## html
1456
-
1457
- ### [{{attr}}](lib/html.js#L23)
1458
-
1459
- Stringify attributes on the options `hash`.
1460
-
1461
- **Params**
1462
-
1463
- * `options` **{Object}**
1464
- * `returns` **{String}**
1465
-
1466
- **Example**
1467
-
1468
- ```html
1469
- <!-- value = 'bar' -->
1470
- <div{{attr foo=value}}></div>
1471
- <!-- results in: <div foo="bar"></div>
1472
- ```
1473
-
1474
- ### [{{css}}](lib/html.js#L45)
1475
-
1476
- Add an array of `<link>` tags. Automatically resolves relative paths to `options.assets` if passed on the context.
1477
-
1478
- **Params**
1479
-
1480
- * `list` **{String|Array}**: One or more stylesheet urls.
1481
- * `returns` **{String}**
1482
-
1483
- **Example**
1484
-
1485
- ```html
1486
- <!-- {stylesheets: ['foo.css', 'bar.css']} -->
1487
- {{css stylesheets}}
1488
-
1489
- <!-- results in: -->
1490
- <!-- <link type="text/css" rel="stylesheet" href="foo.css"> -->
1491
- <!-- <link type="text/css" rel="stylesheet" href="bar.css"> -->
1492
- ```
1493
-
1494
- ### [{{js}}](lib/html.js#L89)
1495
-
1496
- Generate one or more `<script></script>` tags with paths/urls to javascript or coffeescript files.
1497
-
1498
- **Params**
1499
-
1500
- * `context` **{Object}**
1501
- * `returns` **{String}**
1502
-
1503
- **Example**
1504
-
1505
- ```html
1506
- {{js scripts}}
1507
- ```
1508
-
1509
- ### [{{sanitize}}](lib/html.js#L121)
1510
-
1511
- Strip HTML tags from a string, so that only the text nodes are preserved.
1512
-
1513
- **Params**
1514
-
1515
- * `str` **{String}**: The string of HTML to sanitize.
1516
- * `returns` **{String}**
1517
-
1518
- **Example**
1519
-
1520
- ```html
1521
- {{sanitize "<span>foo</span>"}}
1522
- <!-- results in: 'foo' -->
1523
- ```
1524
-
1525
- ### [{{ul}}](lib/html.js#L135)
1526
-
1527
- Block helper for creating unordered lists (`<ul></ul>`)
1528
-
1529
- **Params**
1530
-
1531
- * `context` **{Object}**
1532
- * `options` **{Object}**
1533
- * `returns` **{String}**
1534
-
1535
- ### [{{ol}}](lib/html.js#L154)
1536
-
1537
- Block helper for creating ordered lists (`<ol></ol>`)
1538
-
1539
- **Params**
1540
-
1541
- * `context` **{Object}**
1542
- * `options` **{Object}**
1543
- * `returns` **{String}**
1544
-
1545
- ### [{{thumbnailImage}}](lib/html.js#L176)
1546
-
1547
- Returns a `<figure>` with a thumbnail linked to a full picture
1548
-
1549
- **Params**
1550
-
1551
- * `context` **{Object}**: Object with values/attributes to add to the generated elements:
1552
- * `context.alt` **{String}**
1553
- * `context.src` **{String}**
1554
- * `context.width` **{Number}**
1555
- * `context.height` **{Number}**
1556
- * `returns` **{String}**: HTML `<figure>` element with image and optional caption/link.
1557
-
1558
- ## i18n
1559
-
1560
- ### [{{i18n}}](lib/i18n.js#L18)
1561
-
1562
- i18n helper. See [button-i18n](https://github.com/assemble/buttons)
1563
- for a working example.
1564
-
1565
- **Params**
1566
-
1567
- * `key` **{String}**
1568
- * `options` **{Object}**
1569
- * `returns` **{String}**
1570
-
1571
- ## inflection
1572
-
1573
- ### [{{inflect}}](lib/inflection.js#L30)
1574
-
1575
- Returns either the `singular` or `plural` inflection of a word based on the given `count`.
1576
-
1577
- **Params**
1578
-
1579
- * `count` **{Number}**
1580
- * `singular` **{String}**: The singular form
1581
- * `plural` **{String}**: The plural form
1582
- * `includeCount` **{String}**
1583
- * `returns` **{String}**
1584
-
1585
- **Example**
1586
-
1587
- ```html
1588
- {{inflect 0 "string" "strings"}}
1589
- <!-- "strings" -->
1590
- {{inflect 1 "string" "strings"}}
1591
- <!-- "string" -->
1592
- {{inflect 1 "string" "strings" true}}
1593
- <!-- "1 string" -->
1594
- {{inflect 2 "string" "strings"}}
1595
- <!-- "strings" -->
1596
- {{inflect 2 "string" "strings" true}}
1597
- <!-- "2 strings" -->
1598
- ```
1599
-
1600
- ### [{{ordinalize}}](lib/inflection.js#L58)
1601
-
1602
- Returns an ordinalized number as a string.
1603
-
1604
- **Params**
1605
-
1606
- * `val` **{String}**: The value to ordinalize.
1607
- * `returns` **{String}**: The ordinalized number
1608
-
1609
- **Example**
1610
-
1611
- ```html
1612
- {{ordinalize 1}}
1613
- <!-- '1st' -->
1614
- {{ordinalize 21}}
1615
- <!-- '21st' -->
1616
- {{ordinalize 29}}
1617
- <!-- '29th' -->
1618
- {{ordinalize 22}}
1619
- <!-- '22nd' -->
1620
- ```
1621
-
1622
- ## logging
1623
-
1624
- [logging-helpers](https://github.com/jonathas/logging-helpers).
1625
-
1626
- ## markdown
1627
-
1628
- ### [{{markdown}}](lib/markdown.js#L28)
1629
-
1630
- Block helper that converts a string of inline markdown to HTML.
1631
-
1632
- **Params**
1633
-
1634
- * `context` **{Object}**
1635
- * `options` **{Object}**
1636
- * `returns` **{String}**
1637
-
1638
- **Example**
1639
-
1640
- ```html
1641
- {{#markdown}}
1642
- # Foo
1643
- {{/markdown}}
1644
- <!-- results in: <h1>Foo</h1> -->
1645
- ```
1646
-
1647
- ### [{{md}}](lib/markdown.js#L55)
1648
-
1649
- Read a markdown file from the file system and inject its contents after converting it to HTML.
1650
-
1651
- **Params**
1652
-
1653
- * `context` **{Object}**
1654
- * `options` **{Object}**
1655
- * `returns` **{String}**
1656
-
1657
- **Example**
1658
-
1659
- ```html
1660
- {{md "foo/bar.md"}}
1661
- ```
1662
-
1663
- ## match
1664
-
1665
- ### [{{match}}](lib/match.js#L23)
1666
-
1667
- Returns an array of strings that match the given glob pattern(s). Options may be passed on the options hash or locals.
1668
-
1669
- **Params**
1670
-
1671
- * `files` **{Array|String}**
1672
- * `patterns` **{Array|String}**: One or more glob patterns.
1673
- * `locals` **{Object}**
1674
- * `options` **{Object}**
1675
- * `returns` **{Array}**: Array of matches
1676
-
1677
- **Example**
1678
-
1679
- ```html
1680
- {{match (readdir "foo") "*.js"}}
1681
- {{match (readdir "foo") (toRegex "\\.js$")}}
1682
- ```
1683
-
1684
- ### [{{isMatch}}](lib/match.js#L47)
1685
-
1686
- Returns true if a filepath contains the given pattern. Options may be passed on the options hash or locals.
1687
-
1688
- **Params**
1689
-
1690
- * `filepath` **{String}**
1691
- * `pattern` **{String}**
1692
- * `options` **{Object}**
1693
- * `returns` **{Boolean}**
1694
-
1695
- **Example**
1696
-
1697
- ```html
1698
- {{isMatch "foo.md" "*.md"}}
1699
- <!-- results in: true -->
1700
- ```
1701
-
1702
- ## math
1703
-
1704
- ### [{{abs}}](lib/math.js#L15)
1705
-
1706
- Return the magnitude of `a`.
1707
-
1708
- **Params**
1709
-
1710
- * `a` **{Number}**
1711
- * `returns` **{Number}**
1712
-
1713
- ### [{{add}}](lib/math.js#L31)
1714
-
1715
- Return the sum of `a` plus `b`.
1716
-
1717
- **Params**
1718
-
1719
- * `a` **{Number}**
1720
- * `b` **{Number}**
1721
- * `returns` **{Number}**
1722
-
1723
- ### [{{avg}}](lib/math.js#L54)
1724
-
1725
- Returns the average of all numbers in the given array.
1726
-
1727
- **Params**
1728
-
1729
- * `array` **{Array}**: Array of numbers to add up.
1730
- * `returns` **{Number}**
1731
-
1732
- **Example**
1733
-
1734
- ```html
1735
- {{avg "[1, 2, 3, 4, 5]"}}
1736
- <!-- results in: '3' -->
1737
- ```
1738
-
1739
- ### [{{ceil}}](lib/math.js#L69)
1740
-
1741
- Get the `Math.ceil()` of the given value.
1742
-
1743
- **Params**
1744
-
1745
- * `value` **{Number}**
1746
- * `returns` **{Number}**
1747
-
1748
- ### [{{divide}}](lib/math.js#L84)
1749
-
1750
- Divide `a` by `b`
1751
-
1752
- **Params**
1753
-
1754
- * `a` **{Number}**: numerator
1755
- * `b` **{Number}**: denominator
1756
-
1757
- ### [{{floor}}](lib/math.js#L102)
1758
-
1759
- Get the `Math.floor()` of the given value.
1760
-
1761
- **Params**
1762
-
1763
- * `value` **{Number}**
1764
- * `returns` **{Number}**
1765
-
1766
- ### [{{minus}}](lib/math.js#L118)
1767
-
1768
- Return the difference of `a` minus `b`.
1769
-
1770
- **Params**
1771
-
1772
- * `a` **{Number}**
1773
- * `b` **{Number}**
1774
-
1775
- ### [{{modulo}}](lib/math.js#L137)
1776
-
1777
- Get the remainder of a division operation.
1778
-
1779
- **Params**
1780
-
1781
- * `a` **{Number}**
1782
- * `b` **{Number}**
1783
- * `returns` **{Number}**
1784
-
1785
- ### [{{multiply}}](lib/math.js#L157)
1786
-
1787
- Return the product of `a` times `b`.
1788
-
1789
- **Params**
1790
-
1791
- * `a` **{Number}**: factor
1792
- * `b` **{Number}**: multiplier
1793
- * `returns` **{Number}**
1794
-
1795
- ### [{{plus}}](lib/math.js#L175)
1796
-
1797
- Add `a` by `b`.
1798
-
1799
- **Params**
1800
-
1801
- * `a` **{Number}**: factor
1802
- * `b` **{Number}**: multiplier
1803
-
1804
- ### [{{random}}](lib/math.js#L194)
1805
-
1806
- Generate a random number between two values
1807
-
1808
- **Params**
1809
-
1810
- * `min` **{Number}**
1811
- * `max` **{Number}**
1812
- * `returns` **{String}**
1813
-
1814
- ### [{{remainder}}](lib/math.js#L212)
1815
-
1816
- Get the remainder when `a` is divided by `b`.
1817
-
1818
- **Params**
1819
-
1820
- * `a` **{Number}**: a
1821
- * `b` **{Number}**: b
1822
-
1823
- ### [{{round}}](lib/math.js#L224)
1824
-
1825
- Round the given number.
1826
-
1827
- **Params**
1828
-
1829
- * `number` **{Number}**
1830
- * `returns` **{Number}**
1831
-
1832
- ### [{{subtract}}](lib/math.js#L241)
1833
-
1834
- Return the product of `a` minus `b`.
1835
-
1836
- **Params**
1837
-
1838
- * `a` **{Number}**
1839
- * `b` **{Number}**
1840
- * `returns` **{Number}**
1841
-
1842
- ### [{{sum}}](lib/math.js#L263)
1843
-
1844
- Returns the sum of all numbers in the given array.
1845
-
1846
- **Params**
1847
-
1848
- * `array` **{Array}**: Array of numbers to add up.
1849
- * `returns` **{Number}**
1850
-
1851
- **Example**
1852
-
1853
- ```html
1854
- {{sum "[1, 2, 3, 4, 5]"}}
1855
- <!-- results in: '15' -->
1856
- ```
1857
-
1858
- ### [{{times}}](lib/math.js#L286)
1859
-
1860
- Multiply number `a` by number `b`.
1861
-
1862
- **Params**
1863
-
1864
- * `a` **{Number}**: factor
1865
- * `b` **{Number}**: multiplier
1866
- * `returns` **{Number}**
1867
-
1868
- ## misc
1869
-
1870
- ### [{{option}}](lib/misc.js#L26)
1871
-
1872
- Return the given value of `prop` from `this.options`.
1873
-
1874
- **Params**
1875
-
1876
- * `prop` **{String}**
1877
- * `returns` **{any}**
1878
-
1879
- **Example**
1880
-
1881
- ```html
1882
- <!-- context = {options: {a: {b: {c: 'ddd'}}}} -->
1883
- {{option "a.b.c"}}
1884
- <!-- results => `ddd` -->
1885
- ```
1886
-
1887
- ### [{{noop}}](lib/misc.js#L39)
1888
-
1889
- Block helper that renders the block without taking any arguments.
1890
-
1891
- **Params**
1892
-
1893
- * `options` **{Object}**
1894
- * `returns` **{String}**
1895
-
1896
- ### [{{typeOf}}](lib/misc.js#L59)
1897
-
1898
- Get the native type of the given `value`
1899
-
1900
- **Params**
1901
-
1902
- * `value` **{any}**
1903
- * `returns` **{String}**: Returns the type of value.
1904
-
1905
- **Example**
1906
-
1907
- ```html
1908
- {{typeOf 1}}
1909
- //=> 'number'
1910
- {{typeOf "1"}}
1911
- //=> 'string'
1912
- {{typeOf "foo"}}
1913
- //=> 'string'
1914
- ```
1915
-
1916
- ### [{{withHash}}](lib/misc.js#L71)
1917
-
1918
- Block helper that builds the context for the block
1919
- from the options hash.
1920
-
1921
- **Params**
1922
-
1923
- * `options` **{Object}**: Handlebars provided options object.
1924
-
1925
- ## number
1926
-
1927
- ### [{{bytes}}](lib/number.js#L24)
1928
-
1929
- Format a number to it's equivalent in bytes. If a string is passed, it's length will be formatted and returned.
1930
-
1931
- **Examples:**
1932
-
1933
- * `'foo' => 3 B`
1934
- * `13661855 => 13.66 MB`
1935
- * `825399 => 825.39 kB`
1936
- * `1396 => 1.4 kB`
1937
-
1938
- **Params**
1939
-
1940
- * `number` **{Number|String}**
1941
- * `returns` **{String}**
1942
-
1943
- ### [{{addCommas}}](lib/number.js#L61)
1944
-
1945
- Add commas to numbers
1946
-
1947
- **Params**
1948
-
1949
- * `num` **{Number}**
1950
- * `returns` **{Number}**
1951
-
1952
- ### [{{phoneNumber}}](lib/number.js#L74)
1953
-
1954
- Convert a string or number to a formatted phone number.
1955
-
1956
- **Params**
1957
-
1958
- * `num` **{Number|String}**: The phone number to format, e.g. `8005551212`
1959
- * `returns` **{Number}**: Formatted phone number: `(800) 555-1212`
1960
-
1961
- ### [{{toAbbr}}](lib/number.js#L92)
1962
-
1963
- Abbreviate numbers to the given number of `precision`. This is for
1964
- general numbers, not size in bytes.
1965
-
1966
- **Params**
1967
-
1968
- * `number` **{Number}**
1969
- * `precision` **{Number}**
1970
- * `returns` **{String}**
1971
-
1972
- ### [{{toExponential}}](lib/number.js#L130)
1973
-
1974
- Returns a string representing the given number in exponential notation.
1975
-
1976
- **Params**
1977
-
1978
- * `number` **{Number}**
1979
- * `fractionDigits` **{Number}**: Optional. An integer specifying the number of digits to use after the decimal point. Defaults to as many digits as necessary to specify the number.
1980
- * `returns` **{Number}**
1981
-
1982
- **Example**
1983
-
1984
- ```html
1985
- {{toExponential number digits}};
1986
- ```
1987
-
1988
- ### [{{toFixed}}](lib/number.js#L153)
1989
-
1990
- Formats the given number using fixed-point notation.
1991
-
1992
- **Params**
1993
-
1994
- * `number` **{Number}**
1995
- * `digits` **{Number}**: (Optional) The number of digits to appear after the decimal point; this may be a value between 0 and 20. If this argument is omitted, it is treated as 0.
1996
- * `returns` **{String}**: A string representing the given number using fixed-point notation.
1997
-
1998
- **Example**
1999
-
2000
- ```html
2001
- {{toFixed "1.1234" 2}}
2002
- //=> '1.12'
2003
- ```
2004
-
2005
- ### [{{toFloat}}](lib/number.js#L169)
2006
-
2007
- **Params**
2008
-
2009
- * `number` **{Number}**
2010
- * `returns` **{Number}**
2011
-
2012
- ### [{{toInt}}](lib/number.js#L179)
2013
-
2014
- **Params**
2015
-
2016
- * `number` **{Number}**
2017
- * `returns` **{Number}**
2018
-
2019
- ### [{{toPrecision}}](lib/number.js#L196)
2020
-
2021
- Returns a string representing the `Number` object to the specified precision.
2022
-
2023
- **Params**
2024
-
2025
- * `number` **{Number}**
2026
- * `precision` **{Number}**: (Optional) An integer specifying the number of significant digits. If precison is not between 1 and 100 (inclusive), it will be coerced to `0`.
2027
- * `returns` **{String}**: A string representing a Number object in fixed-point or exponential notation rounded to precision significant digits.
2028
-
2029
- **Example**
2030
-
2031
- ```html
2032
- {{toPrecision "1.1234" 2}}
2033
- //=> '1.1'
2034
- ```
2035
-
2036
- ## object
2037
-
2038
- ### [{{extend}}](lib/object.js#L18)
2039
-
2040
- Extend the context with the properties of other objects.
2041
- A shallow merge is performed to avoid mutating the context.
2042
-
2043
- **Params**
2044
-
2045
- * `objects` **{Object}**: One or more objects to extend.
2046
- * `returns` **{Object}**
2047
-
2048
- ### [{{forIn}}](lib/object.js#L55)
2049
-
2050
- Block helper that iterates over the properties of
2051
- an object, exposing each key and value on the context.
2052
-
2053
- **Params**
2054
-
2055
- * `context` **{Object}**
2056
- * `options` **{Object}**
2057
- * `returns` **{String}**
2058
-
2059
- ### [{{forOwn}}](lib/object.js#L81)
2060
-
2061
- Block helper that iterates over the **own** properties of
2062
- an object, exposing each key and value on the context.
2063
-
2064
- **Params**
2065
-
2066
- * `obj` **{Object}**: The object to iterate over.
2067
- * `options` **{Object}**
2068
- * `returns` **{String}**
2069
-
2070
- ### [{{toPath}}](lib/object.js#L106)
2071
-
2072
- Take arguments and, if they are string or number, convert them to a dot-delineated object property path.
2073
-
2074
- **Params**
2075
-
2076
- * `prop` **{String|Number}**: The property segments to assemble (can be multiple).
2077
- * `returns` **{String}**
2078
-
2079
- ### [{{get}}](lib/object.js#L128)
2080
-
2081
- Use property paths (`a.b.c`) to get a value or nested value from
2082
- the context. Works as a regular helper or block helper.
2083
-
2084
- **Params**
2085
-
2086
- * `prop` **{String}**: The property to get, optionally using dot notation for nested properties.
2087
- * `context` **{Object}**: The context object
2088
- * `options` **{Object}**: The handlebars options object, if used as a block helper.
2089
- * `returns` **{String}**
2090
-
2091
- ### [{{getObject}}](lib/object.js#L149)
2092
-
2093
- Use property paths (`a.b.c`) to get an object from
2094
- the context. Differs from the `get` helper in that this
2095
- helper will return the actual object, including the
2096
- given property key. Also, this helper does not work as a
2097
- block helper.
2098
-
2099
- **Params**
2100
-
2101
- * `prop` **{String}**: The property to get, optionally using dot notation for nested properties.
2102
- * `context` **{Object}**: The context object
2103
- * `returns` **{String}**
2104
-
2105
- ### [{{hasOwn}}](lib/object.js#L167)
2106
-
2107
- Return true if `key` is an own, enumerable property of the given `context` object.
2108
-
2109
- **Params**
2110
-
2111
- * `key` **{String}**
2112
- * `context` **{Object}**: The context object.
2113
- * `returns` **{Boolean}**
2114
-
2115
- **Example**
2116
-
2117
- ```html
2118
- {{hasOwn context key}}
2119
- ```
2120
-
2121
- ### [{{isObject}}](lib/object.js#L183)
2122
-
2123
- Return true if `value` is an object.
2124
-
2125
- **Params**
2126
-
2127
- * `value` **{String}**
2128
- * `returns` **{Boolean}**
2129
-
2130
- **Example**
2131
-
2132
- ```html
2133
- {{isObject "foo"}}
2134
- //=> false
2135
- ```
2136
-
2137
- ### [{{JSONparse}}](lib/object.js#L201)
2138
-
2139
- Parses the given string using `JSON.parse`.
2140
-
2141
- **Params**
2142
-
2143
- * `string` **{String}**: The string to parse
2144
-
2145
- **Example**
2146
-
2147
- ```html
2148
- <!-- string: '{"foo": "bar"}' -->
2149
- {{JSONparse string}}
2150
- <!-- results in: { foo: 'bar' } -->
2151
- ```
2152
-
2153
- ### [{{JSONstringify}}](lib/object.js#L218)
2154
-
2155
- Stringify an object using `JSON.stringify`.
2156
-
2157
- **Params**
2158
-
2159
- * `obj` **{Object}**: Object to stringify
2160
- * `returns` **{String}**
2161
-
2162
- **Example**
2163
-
2164
- ```html
2165
- <!-- object: { foo: 'bar' } -->
2166
- {{JSONstringify object}}
2167
- <!-- results in: '{"foo": "bar"}' -->
2168
- ```
2169
-
2170
- ### [{{merge}}](lib/object.js#L235)
2171
-
2172
- Deeply merge the properties of the given `objects` with the
2173
- context object.
2174
-
2175
- **Params**
2176
-
2177
- * `object` **{Object}**: The target object. Pass an empty object to shallow clone.
2178
- * `objects` **{Object}**
2179
- * `returns` **{Object}**
2180
-
2181
- ### [{{pick}}](lib/object.js#L267)
2182
-
2183
- Pick properties from the context object.
2184
-
2185
- **Params**
2186
-
2187
- * `properties` **{Array|String}**: One or more properties to pick.
2188
- * `context` **{Object}**
2189
- * `options` **{Object}**: Handlebars options object.
2190
- * `returns` **{Object}**: Returns an object with the picked values. If used as a block helper, the values are passed as context to the inner block. If no values are found, the context is passed to the inverse block.
2191
-
2192
- ## path
2193
-
2194
- ### [{{absolute}}](lib/path.js#L20)
2195
-
2196
- Get the directory path segment from the given `filepath`.
2197
-
2198
- **Params**
2199
-
2200
- * `ext` **{String}**
2201
- * `returns` **{String}**
2202
-
2203
- **Example**
2204
-
2205
- ```html
2206
- {{absolute "docs/toc.md"}}
2207
- <!-- results in: 'docs' -->
2208
- ```
2209
-
2210
- ### [{{dirname}}](lib/path.js#L40)
2211
-
2212
- Get the directory path segment from the given `filepath`.
2213
-
2214
- **Params**
2215
-
2216
- * `ext` **{String}**
2217
- * `returns` **{String}**
2218
-
2219
- **Example**
2220
-
2221
- ```html
2222
- {{dirname "docs/toc.md"}}
2223
- <!-- results in: 'docs' -->
2224
- ```
2225
-
2226
- ### [{{relative}}](lib/path.js#L59)
2227
-
2228
- Get the relative filepath from `a` to `b`.
2229
-
2230
- **Params**
2231
-
2232
- * `a` **{String}**
2233
- * `b` **{String}**
2234
- * `returns` **{String}**
2235
-
2236
- **Example**
2237
-
2238
- ```html
2239
- {{relative a b}}
2240
- ```
2241
-
2242
- ### [{{basename}}](lib/path.js#L81)
2243
-
2244
- Get the file extension from the given `filepath`.
2245
-
2246
- **Params**
2247
-
2248
- * `ext` **{String}**
2249
- * `returns` **{String}**
2250
-
2251
- **Example**
2252
-
2253
- ```html
2254
- {{basename "docs/toc.md"}}
2255
- <!-- results in: 'toc.md' -->
2256
- ```
2257
-
2258
- ### [{{stem}}](lib/path.js#L100)
2259
-
2260
- Get the "stem" from the given `filepath`.
2261
-
2262
- **Params**
2263
-
2264
- * `filepath` **{String}**
2265
- * `returns` **{String}**
2266
-
2267
- **Example**
2268
-
2269
- ```html
2270
- {{stem "docs/toc.md"}}
2271
- <!-- results in: 'toc' -->
2272
- ```
2273
-
2274
- ### [{{extname}}](lib/path.js#L119)
2275
-
2276
- Get the file extension from the given `filepath`.
2277
-
2278
- **Params**
2279
-
2280
- * `filepath` **{String}**
2281
- * `returns` **{String}**
2282
-
2283
- **Example**
2284
-
2285
- ```html
2286
- {{extname "docs/toc.md"}}
2287
- <!-- results in: '.md' -->
2288
- ```
2289
-
2290
- ### [{{resolve}}](lib/path.js#L138)
2291
-
2292
- Resolve an absolute path from the given `filepath`.
2293
-
2294
- **Params**
2295
-
2296
- * `filepath` **{String}**
2297
- * `returns` **{String}**
2298
-
2299
- **Example**
2300
-
2301
- ```html
2302
- {{resolve "docs/toc.md"}}
2303
- <!-- results in: '/User/dev/docs/toc.md' -->
2304
- ```
2305
-
2306
- ### [{{segments}}](lib/path.js#L166)
2307
-
2308
- Get specific (joined) segments of a file path by passing a range of array indices.
2309
-
2310
- **Params**
2311
-
2312
- * `filepath` **{String}**: The file path to split into segments.
2313
- * `returns` **{String}**: Returns a single, joined file path.
2314
-
2315
- **Example**
2316
-
2317
- ```html
2318
- {{segments "a/b/c/d" "2" "3"}}
2319
- <!-- results in: 'c/d' -->
2320
-
2321
- {{segments "a/b/c/d" "1" "3"}}
2322
- <!-- results in: 'b/c/d' -->
2323
-
2324
- {{segments "a/b/c/d" "1" "2"}}
2325
- <!-- results in: 'b/c' -->
2326
- ```
2327
-
2328
- ## regex
2329
-
2330
- ### [{{toRegex}}](lib/regex.js#L19)
2331
-
2332
- Convert the given string to a regular expression.
2333
-
2334
- **Params**
2335
-
2336
- * `str` **{String}**
2337
- * `returns` **{RegExp}**
2338
-
2339
- **Example**
2340
-
2341
- ```html
2342
- {{toRegex "foo"}}
2343
- <!-- results in: /foo/ -->
2344
- ```
2345
-
2346
- ### [{{test}}](lib/regex.js#L42)
2347
-
2348
- Returns true if the given `str` matches the given regex. A regex can be passed on the context, or using the [toRegex](#toregex) helper as a subexpression.
2349
-
2350
- **Params**
2351
-
2352
- * `str` **{String}**
2353
- * `returns` **{RegExp}**
2354
-
2355
- **Example**
2356
-
2357
- ```html
2358
- {{test "bar" (toRegex "foo")}}
2359
- <!-- results in: false -->
2360
- {{test "foobar" (toRegex "foo")}}
2361
- <!-- results in: true -->
2362
- {{test "foobar" (toRegex "^foo$")}}
2363
- <!-- results in: false -->
2364
- ```
2365
-
2366
- ## string
2367
-
2368
- ### [{{append}}](lib/string.js#L22)
2369
-
2370
- Append the specified `suffix` to the given string.
2371
-
2372
- **Params**
2373
-
2374
- * `str` **{String}**
2375
- * `suffix` **{String}**
2376
- * `returns` **{String}**
2377
-
2378
- **Example**
2379
-
2380
- ```html
2381
- <!-- given that "item.stem" is "foo" -->
2382
- {{append item.stem ".html"}}
2383
- <!-- results in: 'foo.html' -->
2384
- ```
2385
-
2386
- ### [{{camelcase}}](lib/string.js#L41)
2387
-
2388
- camelCase the characters in the given `string`.
2389
-
2390
- **Params**
2391
-
2392
- * `string` **{String}**: The string to camelcase.
2393
- * `returns` **{String}**
2394
-
2395
- **Example**
2396
-
2397
- ```html
2398
- {{camelcase "foo bar baz"}};
2399
- <!-- results in: 'fooBarBaz' -->
2400
- ```
2401
-
2402
- ### [{{capitalize}}](lib/string.js#L60)
2403
-
2404
- Capitalize the first word in a sentence.
2405
-
2406
- **Params**
2407
-
2408
- * `str` **{String}**
2409
- * `returns` **{String}**
2410
-
2411
- **Example**
2412
-
2413
- ```html
2414
- {{capitalize "foo bar baz"}}
2415
- <!-- results in: "Foo bar baz" -->
2416
- ```
2417
-
2418
- ### [{{capitalizeAll}}](lib/string.js#L77)
2419
-
2420
- Capitalize all words in a string.
2421
-
2422
- **Params**
2423
-
2424
- * `str` **{String}**
2425
- * `returns` **{String}**
2426
-
2427
- **Example**
2428
-
2429
- ```html
2430
- {{capitalizeAll "foo bar baz"}}
2431
- <!-- results in: "Foo Bar Baz" -->
2432
- ```
2433
-
2434
- ### [{{center}}](lib/string.js#L95)
2435
-
2436
- Center a string using non-breaking spaces
2437
-
2438
- **Params**
2439
-
2440
- * `str` **{String}**
2441
- * `spaces` **{String}**
2442
- * `returns` **{String}**
2443
-
2444
- ### [{{chop}}](lib/string.js#L125)
2445
-
2446
- Like trim, but removes both extraneous whitespace **and non-word characters** from the beginning and end of a string.
2447
-
2448
- **Params**
2449
-
2450
- * `string` **{String}**: The string to chop.
2451
- * `returns` **{String}**
2452
-
2453
- **Example**
2454
-
2455
- ```html
2456
- {{chop "_ABC_"}}
2457
- <!-- results in: 'ABC' -->
2458
-
2459
- {{chop "-ABC-"}}
2460
- <!-- results in: 'ABC' -->
2461
-
2462
- {{chop " ABC "}}
2463
- <!-- results in: 'ABC' -->
2464
- ```
2465
-
2466
- ### [{{dashcase}}](lib/string.js#L143)
2467
-
2468
- dash-case the characters in `string`. Replaces non-word characters and periods with hyphens.
2469
-
2470
- **Params**
2471
-
2472
- * `string` **{String}**
2473
- * `returns` **{String}**
2474
-
2475
- **Example**
2476
-
2477
- ```html
2478
- {{dashcase "a-b-c d_e"}}
2479
- <!-- results in: 'a-b-c-d-e' -->
2480
- ```
2481
-
2482
- ### [{{dotcase}}](lib/string.js#L162)
2483
-
2484
- dot.case the characters in `string`.
2485
-
2486
- **Params**
2487
-
2488
- * `string` **{String}**
2489
- * `returns` **{String}**
2490
-
2491
- **Example**
2492
-
2493
- ```html
2494
- {{dotcase "a-b-c d_e"}}
2495
- <!-- results in: 'a.b.c.d.e' -->
2496
- ```
2497
-
2498
- ### [{{downcase}}](lib/string.js#L182)
2499
-
2500
- Lowercase all of the characters in the given string. Alias for [lowercase](#lowercase).
2501
-
2502
- **Params**
2503
-
2504
- * `string` **{String}**
2505
- * `returns` **{String}**
2506
-
2507
- **Example**
2508
-
2509
- ```html
2510
- {{downcase "aBcDeF"}}
2511
- <!-- results in: 'abcdef' -->
2512
- ```
2513
-
2514
- ### [{{ellipsis}}](lib/string.js#L202)
2515
-
2516
- Truncates a string to the specified `length`, and appends it with an elipsis, `…`.
2517
-
2518
- **Params**
2519
-
2520
- * `str` **{String}**
2521
- * `length` **{Number}**: The desired length of the returned string.
2522
- * `returns` **{String}**: The truncated string.
2523
-
2524
- **Example**
2525
-
2526
- ```html
2527
- {{ellipsis (sanitize "<span>foo bar baz</span>"), 7}}
2528
- <!-- results in: 'foo bar…' -->
2529
- {{ellipsis "foo bar baz", 7}}
2530
- <!-- results in: 'foo bar…' -->
2531
- ```
2532
-
2533
- ### [{{hyphenate}}](lib/string.js#L223)
2534
-
2535
- Replace spaces in a string with hyphens.
2536
-
2537
- **Params**
2538
-
2539
- * `str` **{String}**
2540
- * `returns` **{String}**
2541
-
2542
- **Example**
2543
-
2544
- ```html
2545
- {{hyphenate "foo bar baz qux"}}
2546
- <!-- results in: "foo-bar-baz-qux" -->
2547
- ```
2548
-
2549
- ### [{{isString}}](lib/string.js#L240)
2550
-
2551
- Return true if `value` is a string.
2552
-
2553
- **Params**
2554
-
2555
- * `value` **{String}**
2556
- * `returns` **{Boolean}**
2557
-
2558
- **Example**
2559
-
2560
- ```html
2561
- {{isString "foo"}}
2562
- <!-- results in: 'true' -->
2563
- ```
2564
-
2565
- ### [{{lowercase}}](lib/string.js#L256)
2566
-
2567
- Lowercase all characters in the given string.
2568
-
2569
- **Params**
2570
-
2571
- * `str` **{String}**
2572
- * `returns` **{String}**
2573
-
2574
- **Example**
2575
-
2576
- ```html
2577
- {{lowercase "Foo BAR baZ"}}
2578
- <!-- results in: 'foo bar baz' -->
2579
- ```
2580
-
2581
- ### [{{occurrences}}](lib/string.js#L278)
2582
-
2583
- Return the number of occurrences of `substring` within the given `string`.
2584
-
2585
- **Params**
2586
-
2587
- * `str` **{String}**
2588
- * `substring` **{String}**
2589
- * `returns` **{Number}**: Number of occurrences
2590
-
2591
- **Example**
2592
-
2593
- ```html
2594
- {{occurrences "foo bar foo bar baz" "foo"}}
2595
- <!-- results in: 2 -->
2596
- ```
2597
-
2598
- ### [{{pascalcase}}](lib/string.js#L303)
2599
-
2600
- PascalCase the characters in `string`.
2601
-
2602
- **Params**
2603
-
2604
- * `string` **{String}**
2605
- * `returns` **{String}**
2606
-
2607
- **Example**
2608
-
2609
- ```html
2610
- {{pascalcase "foo bar baz"}}
2611
- <!-- results in: 'FooBarBaz' -->
2612
- ```
2613
-
2614
- ### [{{pathcase}}](lib/string.js#L323)
2615
-
2616
- path/case the characters in `string`.
2617
-
2618
- **Params**
2619
-
2620
- * `string` **{String}**
2621
- * `returns` **{String}**
2622
-
2623
- **Example**
2624
-
2625
- ```html
2626
- {{pathcase "a-b-c d_e"}}
2627
- <!-- results in: 'a/b/c/d/e' -->
2628
- ```
2629
-
2630
- ### [{{plusify}}](lib/string.js#L343)
2631
-
2632
- Replace spaces in the given string with pluses.
2633
-
2634
- **Params**
2635
-
2636
- * `str` **{String}**: The input string
2637
- * `returns` **{String}**: Input string with spaces replaced by plus signs
2638
-
2639
- **Example**
2640
-
2641
- ```html
2642
- {{plusify "foo bar baz"}}
2643
- <!-- results in: 'foo+bar+baz' -->
2644
- ```
2645
-
2646
- ### [{{prepend}}](lib/string.js#L363)
2647
-
2648
- Prepends the given `string` with the specified `prefix`.
2649
-
2650
- **Params**
2651
-
2652
- * `str` **{String}**
2653
- * `prefix` **{String}**
2654
- * `returns` **{String}**
2655
-
2656
- **Example**
2657
-
2658
- ```html
2659
- <!-- given that "val" is "bar" -->
2660
- {{prepend val "foo-"}}
2661
- <!-- results in: 'foo-bar' -->
2662
- ```
2663
-
2664
- ### [{{raw}}](lib/string.js#L385)
2665
-
2666
- Render a block without processing mustache templates inside the block.
2667
-
2668
- **Params**
2669
-
2670
- * `options` **{Object}**
2671
- * `returns` **{String}**
2672
-
2673
- **Example**
2674
-
2675
- ```html
2676
- {{{{#raw}}}}
2677
- {{foo}}
2678
- {{{{/raw}}}}
2679
- <!-- results in: '{{foo}}' -->
2680
- ```
2681
-
2682
- ### [{{remove}}](lib/string.js#L413)
2683
-
2684
- Remove all occurrences of `substring` from the given `str`.
2685
-
2686
- **Params**
2687
-
2688
- * `str` **{String}**
2689
- * `substring` **{String}**
2690
- * `returns` **{String}**
2691
-
2692
- **Example**
2693
-
2694
- ```html
2695
- {{remove "a b a b a b" "a "}}
2696
- <!-- results in: 'b b b' -->
2697
- ```
2698
-
2699
- ### [{{removeFirst}}](lib/string.js#L432)
2700
-
2701
- Remove the first occurrence of `substring` from the given `str`.
2702
-
2703
- **Params**
2704
-
2705
- * `str` **{String}**
2706
- * `substring` **{String}**
2707
- * `returns` **{String}**
2708
-
2709
- **Example**
2710
-
2711
- ```html
2712
- {{remove "a b a b a b" "a"}}
2713
- <!-- results in: ' b a b a b' -->
2714
- ```
2715
-
2716
- ### [{{replace}}](lib/string.js#L452)
2717
-
2718
- Replace all occurrences of substring `a` with substring `b`.
2719
-
2720
- **Params**
2721
-
2722
- * `str` **{String}**
2723
- * `a` **{String}**
2724
- * `b` **{String}**
2725
- * `returns` **{String}**
2726
-
2727
- **Example**
2728
-
2729
- ```html
2730
- {{replace "a b a b a b" "a" "z"}}
2731
- <!-- results in: 'z b z b z b' -->
2732
- ```
2733
-
2734
- ### [{{replaceFirst}}](lib/string.js#L473)
2735
-
2736
- Replace the first occurrence of substring `a` with substring `b`.
2737
-
2738
- **Params**
2739
-
2740
- * `str` **{String}**
2741
- * `a` **{String}**
2742
- * `b` **{String}**
2743
- * `returns` **{String}**
2744
-
2745
- **Example**
2746
-
2747
- ```html
2748
- {{replace "a b a b a b" "a" "z"}}
2749
- <!-- results in: 'z b a b a b' -->
2750
- ```
2751
-
2752
- ### [{{reverse}}](lib/string.js#L492)
2753
-
2754
- Reverse a string.
2755
-
2756
- **Params**
2757
-
2758
- * `str` **{String}**
2759
- * `returns` **{String}**
2760
-
2761
- **Example**
2762
-
2763
- ```html
2764
- {{reverse "abcde"}}
2765
- <!-- results in: 'edcba' -->
2766
- ```
2767
-
2768
- ### [{{sentence}}](lib/string.js#L509)
2769
-
2770
- Sentence case the given string
2771
-
2772
- **Params**
2773
-
2774
- * `str` **{String}**
2775
- * `returns` **{String}**
2776
-
2777
- **Example**
2778
-
2779
- ```html
2780
- {{sentence "hello world. goodbye world."}}
2781
- <!-- results in: 'Hello world. Goodbye world.' -->
2782
- ```
2783
-
2784
- ### [{{snakecase}}](lib/string.js#L528)
2785
-
2786
- snake_case the characters in the given `string`.
2787
-
2788
- **Params**
2789
-
2790
- * `string` **{String}**
2791
- * `returns` **{String}**
2792
-
2793
- **Example**
2794
-
2795
- ```html
2796
- {{snakecase "a-b-c d_e"}}
2797
- <!-- results in: 'a_b_c_d_e' -->
2798
- ```
2799
-
2800
- ### [{{split}}](lib/string.js#L547)
2801
-
2802
- Split `string` by the given `character`.
2803
-
2804
- **Params**
2805
-
2806
- * `string` **{String}**: The string to split.
2807
- * `returns` **{String}** `character`: Default is an empty string.
2808
-
2809
- **Example**
2810
-
2811
- ```html
2812
- {{split "a,b,c" ","}}
2813
- <!-- results in: ['a', 'b', 'c'] -->
2814
- ```
2815
-
2816
- ### [{{startsWith}}](lib/string.js#L572)
2817
-
2818
- Tests whether a string begins with the given prefix.
2819
-
2820
- **Params**
2821
-
2822
- * `prefix` **{String}**
2823
- * `testString` **{String}**
2824
- * `options` **{String}**
2825
- * `returns` **{String}**
2826
-
2827
- **Example**
2828
-
2829
- ```html
2830
- {{#startsWith "Goodbye" "Hello, world!"}}
2831
- Whoops
2832
- {{else}}
2833
- Bro, do you even hello world?
2834
- {{/startsWith}}
2835
- ```
2836
-
2837
- ### [{{titleize}}](lib/string.js#L596)
2838
-
2839
- Title case the given string.
2840
-
2841
- **Params**
2842
-
2843
- * `str` **{String}**
2844
- * `returns` **{String}**
2845
-
2846
- **Example**
2847
-
2848
- ```html
2849
- {{titleize "this is title case"}}
2850
- <!-- results in: 'This Is Title Case' -->
2851
- ```
2852
-
2853
- ### [{{trim}}](lib/string.js#L623)
2854
-
2855
- Removes extraneous whitespace from the beginning and end of a string.
2856
-
2857
- **Params**
2858
-
2859
- * `string` **{String}**: The string to trim.
2860
- * `returns` **{String}**
2861
-
2862
- **Example**
2863
-
2864
- ```html
2865
- {{trim " ABC "}}
2866
- <!-- results in: 'ABC' -->
2867
- ```
2868
-
2869
- ### [{{trimLeft}}](lib/string.js#L639)
2870
-
2871
- Removes extraneous whitespace from the beginning of a string.
2872
-
2873
- **Params**
2874
-
2875
- * `string` **{String}**: The string to trim.
2876
- * `returns` **{String}**
2877
-
2878
- **Example**
2879
-
2880
- ```html
2881
- {{trim " ABC "}}
2882
- <!-- results in: 'ABC ' -->
2883
- ```
2884
-
2885
- ### [{{trimRight}}](lib/string.js#L657)
2886
-
2887
- Removes extraneous whitespace from the end of a string.
2888
-
2889
- **Params**
2890
-
2891
- * `string` **{String}**: The string to trim.
2892
- * `returns` **{String}**
2893
-
2894
- **Example**
2895
-
2896
- ```html
2897
- {{trimRight " ABC "}}
2898
- <!-- results in: ' ABC' -->
2899
- ```
2900
-
2901
- ### [{{truncate}}](lib/string.js#L680)
2902
-
2903
- Truncate a string to the specified `length`. Also see [ellipsis](#ellipsis).
2904
-
2905
- **Params**
2906
-
2907
- * `str` **{String}**
2908
- * `limit` **{Number}**: The desired length of the returned string.
2909
- * `suffix` **{String}**: Optionally supply a string to use as a suffix to denote when the string has been truncated. Otherwise an ellipsis (`…`) will be used.
2910
- * `returns` **{String}**: The truncated string.
2911
-
2912
- **Example**
2913
-
2914
- ```html
2915
- truncate("foo bar baz", 7);
2916
- <!-- results in: 'foo bar' -->
2917
- truncate(sanitize("<span>foo bar baz</span>", 7));
2918
- <!-- results in: 'foo bar' -->
2919
- ```
2920
-
2921
- ### [{{truncateWords}}](lib/string.js#L712)
2922
-
2923
- Truncate a string to have the specified number of words. Also see [truncate](#truncate).
2924
-
2925
- **Params**
2926
-
2927
- * `str` **{String}**
2928
- * `limit` **{Number}**: The desired length of the returned string.
2929
- * `suffix` **{String}**: Optionally supply a string to use as a suffix to denote when the string has been truncated.
2930
- * `returns` **{String}**: The truncated string.
2931
-
2932
- **Example**
2933
-
2934
- ```html
2935
- truncateWords("foo bar baz", 1);
2936
- <!-- results in: 'foo…' -->
2937
- truncateWords("foo bar baz", 2);
2938
- <!-- results in: 'foo bar…' -->
2939
- truncateWords("foo bar baz", 3);
2940
- <!-- results in: 'foo bar baz' -->
2941
- ```
2942
-
2943
- ### [{{upcase}}](lib/string.js#L742)
2944
-
2945
- Uppercase all of the characters in the given string. Alias for [uppercase](#uppercase).
2946
-
2947
- **Params**
2948
-
2949
- * `string` **{String}**
2950
- * `returns` **{String}**
2951
-
2952
- **Example**
2953
-
2954
- ```html
2955
- {{upcase "aBcDeF"}}
2956
- <!-- results in: 'ABCDEF' -->
2957
- ```
2958
-
2959
- ### [{{uppercase}}](lib/string.js#L763)
2960
-
2961
- Uppercase all of the characters in the given string. If used as a block helper it will uppercase the entire block. This helper does not support inverse blocks.
2962
-
2963
- **Params**
2964
-
2965
- * `str` **{String}**: The string to uppercase
2966
- * `options` **{Object}**: Handlebars options object
2967
- * `returns` **{String}**
2968
-
2969
- **Example**
2970
-
2971
- ```html
2972
- {{uppercase "aBcDeF"}}
2973
- <!-- results in: 'ABCDEF' -->
2974
- ```
2975
-
2976
- ## url
2977
-
2978
- ### [{{encodeURI}}](lib/url.js#L19)
2979
-
2980
- Encodes a Uniform Resource Identifier (URI) component
2981
- by replacing each instance of certain characters by
2982
- one, two, three, or four escape sequences representing
2983
- the UTF-8 encoding of the character.
2984
-
2985
- **Params**
2986
-
2987
- * `str` **{String}**: The un-encoded string
2988
- * `returns` **{String}**: The endcoded string
2989
-
2990
- ### [{{escape}}](lib/url.js#L34)
2991
-
2992
- Escape the given string by replacing characters with escape sequences.
2993
- Useful for allowing the string to be used in a URL, etc.
2994
-
2995
- **Params**
2996
-
2997
- * `str` **{String}**
2998
- * `returns` **{String}**: Escaped string.
2999
-
3000
- ### [{{decodeURI}}](lib/url.js#L48)
3001
-
3002
- Decode a Uniform Resource Identifier (URI) component.
3003
-
3004
- **Params**
3005
-
3006
- * `str` **{String}**
3007
- * `returns` **{String}**
3008
-
3009
- ### [{{url_encode}}](lib/url.js#L59)
3010
-
3011
- Alias for [encodeURI](#encodeuri).
3012
-
3013
- ### [{{url_decode}}](lib/url.js#L68)
3014
-
3015
- Alias for [decodeURI](#decodeuri).
3016
-
3017
- ### [{{urlResolve}}](lib/url.js#L82)
3018
-
3019
- Take a base URL, and a href URL, and resolve them as a
3020
- browser would for an anchor tag.
3021
-
3022
- **Params**
3023
-
3024
- * `base` **{String}**
3025
- * `href` **{String}**
3026
- * `returns` **{String}**
3027
-
3028
- ### [{{urlParse}}](lib/url.js#L94)
3029
-
3030
- Parses a `url` string into an object.
3031
-
3032
- **Params**
3033
-
3034
- * `str` **{String}**: URL string
3035
- * `returns` **{String}**: Returns stringified JSON
3036
-
3037
- ### [{{stripQuerystring}}](lib/url.js#L106)
3038
-
3039
- Strip the query string from the given `url`.
3040
-
3041
- **Params**
3042
-
3043
- * `url` **{String}**
3044
- * `returns` **{String}**: the url without the queryString
3045
-
3046
- ### [{{stripProtocol}}](lib/url.js#L126)
3047
-
3048
- Strip protocol from a `url`. Useful for displaying media that may have an 'http' protocol on secure connections.
3049
-
3050
- **Params**
3051
-
3052
- * `str` **{String}**
3053
- * `returns` **{String}**: the url with http protocol stripped
3054
-
3055
- **Example**
3056
-
3057
- ```html
3058
- <!-- url = 'http://foo.bar' -->
3059
- {{stripProtocol url}}
3060
- <!-- results in: '//foo.bar' -->
3061
- ```
3062
-
3063
- ***
3064
-
3065
- ## Utils
3066
-
3067
- The following utils are exposed on `.utils`.
3068
-
3069
- ### [{{changecase}}](lib/utils/index.js#L54)
3070
-
3071
- Change casing on the given `string`, optionally passing a delimiter to use between words in the returned string.
3072
-
3073
- **Params**
3074
-
3075
- * `string` **{String}**: The string to change.
3076
- * `returns` **{String}**
3077
-
3078
- **Example**
3079
-
3080
- ```html
3081
- utils.changecase('fooBarBaz');
3082
- //=> 'foo bar baz'
3083
-
3084
- utils.changecase('fooBarBaz' '-');
3085
- //=> 'foo-bar-baz'
3086
- ```
3087
-
3088
- ### [{{random}}](lib/utils/index.js#L80)
3089
-
3090
- Generate a random number
3091
-
3092
- **Params**
3093
-
3094
- * `min` **{Number}**
3095
- * `max` **{Number}**
3096
- * `returns` **{Number}**
3097
-
3098
104
  ## How to Contribute
3099
105
  clone the repository locally and run 'npm i' in the root. Now that you've set up your workspace, you're ready to contribute changes to the `fumanchu` repository you can refer to the [CONTRIBUTING](CONTRIBUTING.md) guide. If you have any questions please feel free to ask by creating an issue and label it `question`.
3100
106