@timkendrick/handlebars-core-helpers v0.1.5
handlebars-core-helpers
Useful helpers for Handlebars templates
Included helpers
Logic helpers: -
{{ eq value1 value2 [...valueN] }}– Returntrueif all arguments are strictly equal to each other, otherwise returnfalse-{{ not-eq value1 value2 [...valueN] }}– Returntrueif all arguments are not strictly equal to each other, otherwise returnfalse-{{ not value }}– Returntrueifvalueis empty, otherwise returnfalse-{{ and value1 value2 [...valueN] }}– Returntrueif all arguments are not empty, otherwise returnfalse-{{ or value1 value2 [...valueN] }}– Returntrueif at least one argument is not empty, otherwise returnfalse-{{ gt value1 value2 }}– Returntrueifvalue1 > value2, otherwise returnfalse-{{ gte value1 value2 }}– Returntrueifvalue1 >= value2, otherwise returnfalse-{{ lt value1 value2 }}– Returntrueifvalue1 < value2, otherwise returnfalse-{{ lte value1 value2 }}– Returntrueifvalue1 <= value2, otherwise returnfalseDatatype helpers: -
{{ is-undefined value }}– Returntrueifvalueisundefined, otherwise returnfalse-{{ is-null value }}– Returntrueifvalueisnull, otherwise returnfalse-{{ is-boolean value }}– Returntrueifvalueis a boolean, otherwise returnfalse-{{ is-number value }}– Returntrueifvalueis a number, otherwise returnfalse-{{ is-string value }}– Returntrueifvalueis a string, otherwise returnfalse-{{ is-object value }}– Returntrueifvalueis a non-null object, otherwise returnfalse-{{ is-symbol value }}– Returntrueifvalueis an ES6 Symbol, otherwise returnfalse-{{ is-function value }}– Returntrueifvalueis a function, otherwise returnfalse-{{ is-array value }}– Returntrueifvalueis an array, otherwise returnfalse-{{ is-date value }}– Returntrueifvalueis a Date object, otherwise returnfalse-{{ is-regexp value }}– Returntrueifvalueis a RegExp object, otherwise returnfalse-{{ is-numeric value }}– Returntrueifvaluecan be coerced to a number, otherwise returnfalseString helpers: -
{{ concat value1 value2 [...valueN] separator=[separator=''] }}– Return a concatenated string consisting of all arguments joined together byseparator-{{ replace source pattern replacement }}– Replace first occurence ofpatterninsourcewithreplacement-{{ starts-with haystack needle }}– Returntrueifhaystackstarts withneedle, otherwise returnfalse-{{ escape-newlines value }}– Replace\nand\rcharacters invaluewith
and
HTML entities (useful to preserve formatting inwhite-space: preelements) -{{ nl2br value }}– Replace newline characters invaluewith<br/>HTML tags -{{ wrap value left right }}– Return an HTML-safe string consisting of an HTML-escapedvaluewrapped between unescapedleftandrightHTML segments -{{ safe value }}– Return an HTML-safe string representation ofvalueDate helpers: -
{{ timestamp date }}– Return the UNIX timestamp corresponding todate, e.g.1262304000-{{ date date }}– deprecated Return a short date label corresponding todate, e.g."Mon 1 Jan 1970"(uses UTC time).Serialization helpers: -
{{ json value {[indent=undefined]} }}– Return a JSON-encoded string representation ofvalue-{{ parse-json value }}– Return the object that results from parsing thevalueJSON string -{{ urlencode value }}– Return a URL-encoded representation ofvalue-{{ urldecode value }}– Return a version ofvaluewith URL entities decoded