# all(values, options)
Output a block (or its inverse) based on whether or not all of the supplied arguments are truthy.
Parameters
Name | Types | Description |
---|---|---|
values | ...* |
One or more values to test against. |
options | Object |
Returns
String|Boolean
# and(left, right, options)
Output a block (or its inverse) based on whether or not both of the supplied arguments are truthy.
Parameters
Name | Types | Description |
---|---|---|
left | * |
|
right | * |
|
options | Object |
Returns
String
# any(values, options)
Output a block (or its inverse) based on whether or not any of the supplied arguments are truthy.
Parameters
Name | Types | Description |
---|---|---|
values | ...* |
One or more values to test against. |
options | Object |
Returns
String|Boolean
# around(items, center, padding, block)
Slices a list based on a center-point and a maximum amount of "padding" before and after. Useful for pagination. Supports an optional offset
hash option in case your center value isn't matching up with your array indexes.
Parameters
Name | Types | Description |
---|---|---|
items | Array |
- Collection to iterate over. |
center | Number |
- The center-point of the collection (for example, current page). |
padding | Number |
- The amount of items to allow before or after the center. |
block | Object |
Returns
String
# average(arr)
Average an array of numeric values.
Parameters
Name | Types | Description |
---|---|---|
arr | Array |
Returns
Number
Returns the average of all values.
# capitalize(str)
Capitalize the first letter of a String.
Parameters
Name | Types | Description |
---|---|---|
str | String |
* |
Returns
String
# capitalizeWords(str)
Capitalize each word in a String. Works with punctuation and international characters.
Parameters
Name | Types | Description |
---|---|---|
str | String |
* |
Returns
String
# compare(left, operator, right, options)
Compare two values using logical operators.
Parameters
Name | Types | Description |
---|---|---|
left | * |
|
operator | String |
|
right | * |
|
options | Object |
Returns
(String|Boolean)
formatted html if block, true/false if inline
# concat(items)
Concatenate items into a single string.
Parameters
Name | Types | Description |
---|---|---|
items | ...* |
Returns
string
# defaultTo(value)
Output the first provided value that exists, or fallback to a default if none do.
Parameters
Name | Types | Description |
---|---|---|
value | ...* |
Returns
String
# dummyImgSrc(width, height, options)
Returns an escaped data URI for a placeholder image that can be used as the src attribute of an img element.
Parameters
Name | Types | Description |
---|---|---|
width | Number |
|
height | Number |
|
options | Object |
Returns
String
# math(left, operator, right, options)
Perform mathematical operations on one or two values.
Parameters
Name | Types | Description |
---|---|---|
left | * |
|
operator | String |
|
right | * |
|
options | Object |
Returns
Number
# maybe()
Output a block randomly (50% chance of being output). Useful for prototyping multiple content scenarios, outputting one or two "dummy" blocks of markup.
# or(left, right, options)
Output a block (or its inverse) based on whether or not either of the supplied arguments are truthy.
Parameters
Name | Types | Description |
---|---|---|
left | * |
|
right | * |
|
options | Object |
Returns
String
# random(method, options, options.hash)
Generate a random integer or any other type of random content supported by Chance.js.
Parameters
Name | Types | Description |
---|---|---|
method | String |
- Chance method to use. |
options | Object |
|
options.hash | Object |
- Additional options to pass to method. |
Returns
*
# randomItem(items)
Return only one random item. If only one argument is provided and it is an array, it will return a random item from that array. Otherwise it will return one of the arguments.
Parameters
Name | Types | Description |
---|---|---|
items | ...* |
Returns
One random item.
# replaceAll(input, find, replace)
Replace all occurrences of a string in another string Can also be used on numbers, though they'll be treated as strings. Case sensitive
Parameters
Name | Types | Description |
---|---|---|
input | Number |
String |
find | Number |
String |
replace | Number |
String |
Returns
String
# split(input, separator)
Splits a string or number by a separator string or number Returns an array that can be iterated over
Parameters
Name | Types | Description |
---|---|---|
input | Number |
String |
separator | Number |
String |
Returns
Array
# module.exports(name, options)
Returns the contents of the SVG at the specified path, with any attributes passed along via the hash included on the root element. Inspired by https://github.com/aredridel/npm-handlebars-helper-svg
Parameters
Name | Types | Description |
---|---|---|
name | String |
- The path to the SVG. The extension may be omitted. |
options | Object |
Returns
String
# module.exports.create(settings, settings.basePath, settings.extName, settings.omitAttr)
Returns a new instance of the svg helper with settings applied. Useful for defining a base path for the project so you don't have to specify it for every usage of the helper.
Parameters
Name | Types | Description |
---|---|---|
settings | Object |
|
settings.basePath | String |
- Base path for file lookups. |
settings.extName | String |
- Extension to use when it is omitted. |
settings.omitAttr | Array |
- Attributes to strip from the SVG root element. |
# timestamp(context)
Format a date or time using Moment.js. Defaults to UTC mode since most use-cases in markup-land do not take timezones into account, which results in some counter-intuitive output and inconsistent behavior.
Parameters
Name | Types | Description |
---|---|---|
context | Date |
String |
Returns
String
# toFixed(num)
Format number to two fixed decimal points (like a price).
Parameters
Name | Types | Description |
---|---|---|
num | Number |
String |
Returns
String
# toFraction(value)
Format a decimal as a fractional HTML entity if possible.
Parameters
Name | Types | Description |
---|---|---|
value | Number |
Returns
String|Number
# toJSON(str)
Converts a string to JSON; useful when used in helper sub-expressions.
Parameters
Name | Types | Description |
---|---|---|
str | String |
Returns
Array|Object
# toSlug(str)
Format a string as a lowercase, URL-friendly value.
Parameters
Name | Types | Description |
---|---|---|
str | String |
Returns
String
# toTitle(name)
Strip leading alphanumeric characters plus spaces from a string. Useful for converting filenames to more usable strings or IDs.
Parameters
Name | Types | Description |
---|---|---|
name | String |
Returns
String