"example":"{{#filter [1, 2, 3] 2}}2 Found{{else}}2 not found{{/filter}}",
"description":"<p>Block helper that filters the given array and renders the block for values that evaluate to <code>true</code>, otherwise the inverse block is returned.</p>\n"
"description":"<p>Returns the first item, or first <code>n</code> items of an array.</p>\n"
},
"forEach":{
@ -185,7 +199,7 @@
"array"
],
"numArgs":1,
"example":"handlebars <!-- accounts = [ {'name': 'John', 'email': 'john@example.com'}, {'name': 'Malcolm', 'email': 'malcolm@example.com'}, {'name': 'David', 'email': 'david@example.com'} ] --> {{#forEach accounts}} <a href=\"mailto:{{ email }}\" title=\"Send an email to {{ name }}\"> {{ name }} </a>{{#unless isLast}}, {{/unless}} {{/forEach}} ",
"example":"{{#forEach [{ 'name': 'John' }] }} {{ name }} {{/forEach}}",
"description":"<p>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: - <code>index</code> - <code>total</code> - <code>isFirst</code> - <code>isLast</code> Also, <code>@index</code> is exposed as a private variable, and additional private variables may be defined as hash arguments.</p>\n"
"example":"{{#inArray [1, 2, 3] 2}} 2 exists {{else}} 2 does not exist {{/inArray}} -> 2 exists",
"description":"<p>Block helper that renders the block if an array has the given <code>value</code>. Optionally specify an inverse block to render when the array does not have the given value.</p>\n"
"description":"<p>Join all elements of array into a string, optionally using a given separator.</p>\n"
},
"equalsLength":{
@ -231,6 +245,7 @@
"options"
],
"numArgs":3,
"example":"{{equalsLength [1, 2, 3] 3}} -> true",
"description":"<p>Returns true if the the length of the given <code>value</code> is equal to the given <code>length</code>. Can be used as a block or inline helper.</p>\n"
},
"last":{
@ -239,7 +254,7 @@
"n"
],
"numArgs":2,
"example":"handlebars <!-- var value = ['a', 'b', 'c', 'd', 'e'] --> {{last value}} <!-- results in: ['e'] --> {{last value 2}} <!-- results in: ['d', 'e'] --> {{last value 3}} <!-- results in: ['c', 'd', 'e'] --> ",
"example":"{{last [1, 2, 3]}} -> 3",
"description":"<p>Returns the last item, or last <code>n</code> items of an array or string. Opposite of <a href=\"#first\">first</a>.</p>\n"
"description":"<p>Returns the length of the given string or array.</p>\n"
},
"lengthEqual":{
@ -257,6 +272,7 @@
"options"
],
"numArgs":3,
"example":"{{equalsLength [1, 2, 3] 3}} -> true",
"description":"<p>Returns true if the the length of the given <code>value</code> is equal to the given <code>length</code>. Can be used as a block or inline helper.</p>\n"
},
"map":{
@ -265,7 +281,7 @@
"fn"
],
"numArgs":2,
"example":"handlebars <!-- array: ['a', 'b', 'c'], and \"double\" is a fictitious function that duplicates letters --> {{map array double}} <!-- results in: '[\"aa\", \"bb\", \"cc\"]' --> ",
"description":"<p>Map over the given object or array or objects and create an array of values from the given <code>prop</code>. Dot-notation may be used (as a string) to get nested properties.</p>\n"
"description":"<p>Reverse the elements in an array, or the characters in a string.</p>\n"
},
"some":{
@ -292,7 +308,7 @@
"provided"
],
"numArgs":3,
"example":"handlebars <!-- array: [1, 'b', 3] --> {{#some array isString}} Render me if the array has a string. {{else}} Render me if it doesn't. {{/some}} <!-- results in: 'Render me if the array has a string.' --> ",
"example":"{{#some [1, 'b', 3] isString}} string found {{else}} No string found {{/some}} -> string found",
"description":"<p>Block helper that returns the block if the callback returns true for some value in the given array.</p>\n"
"description":"<p>Sort the given <code>array</code>. If an array of objects is passed, you may optionally pass a <code>key</code> to sort on as the second argument. You may alternatively pass a sorting function as the second argument.</p>\n"
"description":"<p>Sort an <code>array</code>. If an array of objects is passed, you may optionally pass a <code>key</code> to sort on as the second argument. You may alternatively pass a sorting function as the second argument.</p>\n"
"description":"<p>Use the items in the array <em>after</em> the specified index as context inside a block. Opposite of <a href=\"#withBefore\">withBefore</a>.</p>\n"
"description":"<p>Use the items in the array <em>before</em> the specified index as context inside a block. Opposite of <a href=\"#withAfter\">withAfter</a>.</p>\n"
"description":"<p>Use the last item or <code>n</code> items in an array as context inside a block. Opposite of <a href=\"#withFirst\">withFirst</a>.</p>\n"
"description":"<p>Block helper that return an array with all duplicate values removed. Best used along with a <a href=\"#each\">each</a> helper.</p>\n"
}
},
@ -389,6 +405,7 @@
"number"
],
"numArgs":1,
"example":"{{ bytes 1386 }} -> 1.4Kb",
"description":"<p>Format a number to it's equivalent in bytes. If a string is passed, it's length will be formatted and returned. <strong>Examples:</strong> - <code>'foo' => 3 B</code> - <code>13661855 => 13.66 MB</code> - <code>825399 => 825.39 kB</code> - <code>1396 => 1.4 kB</code></p>\n"
"description":"<p>Encodes a Uniform Resource Identifier (URI) component by replacing each instance of certain characters by one, two, three, or four escape sequences representing the UTF-8 encoding of the character.</p>\n"
"description":"<p>Escape the given string by replacing characters with escape sequences. Useful for allowing the string to be used in a URL, etc.</p>\n"
"description":"<p>Strip protocol from a <code>url</code>. Useful for displaying media that may have an 'http' protocol on secure connections.</p>\n"
}
},
@ -525,7 +551,7 @@
"suffix"
],
"numArgs":2,
"example":"handlebars <!-- given that \"item.stem\" is \"foo\" --> {{append item.stem \".html\"}} <!-- results in: 'foo.html' --> ",
"description":"<p>Like trim, but removes both extraneous whitespace <strong>and non-word characters</strong> from the beginning and end of a string.</p>\n"
"description":"<p>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.</p>\n"
"example":"{{#and great magnificent}}both{{else}}no{{/and}}",
"description":"<p>Helper that renders the block if <strong>both</strong> 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.</p>\n"
},
"compare":{
@ -836,6 +863,7 @@
"options"
],
"numArgs":4,
"example":"{{compare 10 \"<\" 5 }} -> true",
"description":"<p>Render a block when a comparison of the first and third arguments returns true. The second argument is the [arithemetic operator][operators] to use. You may also optionally specify an inverse block to render when falsy.</p>\n"
},
"contains":{
@ -846,7 +874,7 @@
"options"
],
"numArgs":4,
"example":"handlebars <!-- array = ['a', 'b', 'c'] --> {{#contains array \"d\"}} This will not be rendered. {{else}} This will be rendered. {{/contains}}",
"example":"{{#contains ['a', 'b', 'c'] \"d\"}} This will not be rendered. {{else}} This will be rendered. {{/contains}}",
"description":"<p>Block helper that renders the block if <code>collection</code> has the given <code>value</code>, using strict equality (<code>===</code>) for comparison, otherwise the inverse block is rendered (if specified). If a <code>startIndex</code> is specified and is negative, it is used as the offset from the end of the collection.</p>\n"
"description":"<p>Returns the first value that is not undefined, otherwise the "default" value is returned.</p>\n"
},
"eq":{
@ -864,6 +893,7 @@
"options"
],
"numArgs":3,
"example":"{{#eq 3 3}} equal{{else}} not equal{{/eq}} -> equal",
"description":"<p>Block helper that renders a block if <code>a</code> is <strong>equal to</strong> <code>b</code>. If an inverse block is specified it will be rendered when falsy. You may optionally use the <code>compare=""</code> hash argument for the second value.</p>\n"
"description":"<p>Block helper that renders a block if <code>a</code> is <strong>greater than</strong> <code>b</code>. If an inverse block is specified it will be rendered when falsy. You may optionally use the <code>compare=""</code> hash argument for the second value.</p>\n"
},
"gte":{
@ -882,6 +913,7 @@
"options"
],
"numArgs":3,
"example":"{{#gte 4 3}} greater than or equal{{else}} not greater than{{/gte}} -> greater than or equal",
"description":"<p>Block helper that renders a block if <code>a</code> is <strong>greater than or equal to</strong> <code>b</code>. If an inverse block is specified it will be rendered when falsy. You may optionally use the <code>compare=""</code> hash argument for the second value.</p>\n"
},
"has":{
@ -891,6 +923,7 @@
"options"
],
"numArgs":3,
"example":"{{#has \"foobar\" \"foo\"}} has it{{else}} doesn't{{/has}} -> has it",
"description":"<p>Block helper that renders a block if <code>value</code> has <code>pattern</code>. If an inverse block is specified it will be rendered when falsy.</p>\n"
},
"isFalsey":{
@ -899,6 +932,7 @@
"options"
],
"numArgs":2,
"example":"{{isFalsey \"\" }} -> true",
"description":"<p>Returns true if the given <code>value</code> is falsey. Uses the [falsey][] library for comparisons. Please see that library for more information or to report bugs with this helper.</p>\n"
},
"isTruthy":{
@ -907,6 +941,7 @@
"options"
],
"numArgs":2,
"example":"{{isTruthy \"12\" }} -> true",
"description":"<p>Returns true if the given <code>value</code> is truthy. Uses the [falsey][] library for comparisons. Please see that library for more information or to report bugs with this helper.</p>\n"
},
"ifEven":{
@ -915,7 +950,7 @@
"options"
],
"numArgs":2,
"example":"handlebars {{#ifEven value}} render A {{else}} render B {{/ifEven}} ",
"example":"{{#ifEven 2}} even {{else}} odd {{/ifEven}} -> even",
"description":"<p>Return true if the given value is an even number.</p>\n"
},
"ifNth":{
@ -925,6 +960,7 @@
"options"
],
"numArgs":3,
"example":"{{#ifNth 10 2}} remainder {{else}} no remainder {{/ifNth}} -> remainder",
"description":"<p>Conditionally renders a block if the remainder is zero when <code>a</code> operand is divided by <code>b</code>. If an inverse block is specified it will be rendered when the remainder is <strong>not zero</strong>.</p>\n"
},
"ifOdd":{
@ -933,7 +969,7 @@
"options"
],
"numArgs":2,
"example":"handlebars {{#ifOdd value}} render A {{else}} render B {{/ifOdd}} ",
"example":"{{#ifOdd 3}} odd {{else}} even {{/ifOdd}} -> odd",
"description":"<p>Block helper that renders a block if <code>value</code> is <strong>an odd number</strong>. If an inverse block is specified it will be rendered when falsy.</p>\n"
},
"is":{
@ -943,6 +979,7 @@
"options"
],
"numArgs":3,
"example":"{{#is 3 3}} is {{else}} is not {{/is}} -> is",
"description":"<p>Block helper that renders a block if <code>a</code> is <strong>equal to</strong> <code>b</code>. If an inverse block is specified it will be rendered when falsy. Similar to <a href=\"#eq\">eq</a> but does not do strict equality.</p>\n"
},
"isnt":{
@ -952,6 +989,7 @@
"options"
],
"numArgs":3,
"example":"{{#isnt 3 3}} isnt {{else}} is {{/isnt}} -> is",
"description":"<p>Block helper that renders a block if <code>a</code> is <strong>not equal to</strong> <code>b</code>. If an inverse block is specified it will be rendered when falsy. Similar to <a href=\"#unlesseq\">unlessEq</a> but does not use strict equality for comparisons.</p>\n"
},
"lt":{
@ -960,6 +998,7 @@
"options"
],
"numArgs":2,
"example":"{{#lt 2 3}} less than {{else}} more than or equal {{/lt}} -> less than",
"description":"<p>Block helper that renders a block if <code>a</code> is <strong>less than</strong> <code>b</code>. If an inverse block is specified it will be rendered when falsy. You may optionally use the <code>compare=""</code> hash argument for the second value.</p>\n"
},
"lte":{
@ -969,6 +1008,7 @@
"options"
],
"numArgs":3,
"example":"{{#lte 2 3}} less than or equal {{else}} more than {{/lte}} -> less than or equal",
"description":"<p>Block helper that renders a block if <code>a</code> is <strong>less than or equal to</strong> <code>b</code>. If an inverse block is specified it will be rendered when falsy. You may optionally use the <code>compare=""</code> hash argument for the second value.</p>\n"
},
"neither":{
@ -978,6 +1018,7 @@
"options"
],
"numArgs":3,
"example":"{{#neither null null}} both falsey {{else}} both not falsey {{/neither}} -> both falsey",
"description":"<p>Block helper that renders a block if <strong>neither of</strong> the given values are truthy. If an inverse block is specified it will be rendered when falsy.</p>\n"
},
"not":{
@ -986,6 +1027,7 @@
"options"
],
"numArgs":2,
"example":"{{#not undefined }} falsey {{else}} not falsey {{/not}} -> falsey",
"description":"<p>Returns true if <code>val</code> is falsey. Works as a block or inline helper.</p>\n"
},
"or":{
@ -994,7 +1036,7 @@
"options"
],
"numArgs":2,
"example":"handlebars {{#or a b c}} If any value is true this will be rendered. {{/or}} ",
"example":"{{#or 1 2 undefined }} at least one truthy {{else}} all falsey {{/or}} -> at least one truthy",
"description":"<p>Block helper that renders a block if <strong>any of</strong> the given values is truthy. If an inverse block is specified it will be rendered when falsy.</p>\n"
},
"unlessEq":{
@ -1004,6 +1046,7 @@
"options"
],
"numArgs":3,
"example":"{{#unlessEq 2 1 }} not equal {{else}} equal {{/unlessEq}} -> not equal",
"description":"<p>Block helper that always renders the inverse block <strong>unless <code>a</code> is equal to <code>b</code></strong>.</p>\n"
},
"unlessGt":{
@ -1013,6 +1056,7 @@
"options"
],
"numArgs":3,
"example":"{{#unlessGt 20 1 }} not greater than {{else}} greater than {{/unlessGt}} -> greater than",
"description":"<p>Block helper that always renders the inverse block <strong>unless <code>a</code> is greater than <code>b</code></strong>.</p>\n"
},
"unlessLt":{
@ -1022,6 +1066,7 @@
"options"
],
"numArgs":3,
"example":"{{#unlessLt 20 1 }} greater than or equal {{else}} less than {{/unlessLt}} -> greater than or equal",
"description":"<p>Block helper that always renders the inverse block <strong>unless <code>a</code> is less than <code>b</code></strong>.</p>\n"
},
"unlessGteq":{
@ -1031,6 +1076,7 @@
"options"
],
"numArgs":3,
"example":"{{#unlessGteq 20 1 }} less than {{else}} greater than or equal to {{/unlessGteq}} -> greater than or equal to",
"description":"<p>Block helper that always renders the inverse block <strong>unless <code>a</code> is greater than or equal to <code>b</code></strong>.</p>\n"
},
"unlessLteq":{
@ -1040,6 +1086,7 @@
"options"
],
"numArgs":3,
"example":"{{#unlessLteq 20 1 }} greater than {{else}} less than or equal to {{/unlessLteq}} -> greater than",
"description":"<p>Block helper that always renders the inverse block <strong>unless <code>a</code> is less than or equal to <code>b</code></strong>.</p>\n"
}
},
@ -1050,8 +1097,17 @@
"format"
],
"numArgs":2,
"example":"{{date now \"YYYY\"}}",
"description":"<p>Format a date using moment.js data formatting.</p>\n"
"example":"{{date now \"DD-MM-YYYY\"}} -> 21-01-2021",
"description":"<p>Format a date using moment.js date formatting.</p>\n"
},
"duration":{
"args":[
"time",
"durationType"
],
"numArgs":2,
"example":"{{duration timeLeft \"seconds\"}} -> a few seconds",
"description":"<p>Produce a humanized duration left/until given an amount of time and the type of time measurement.</p>\n"