
Product
Rust Support in Socket Is Now Generally Available
Socket’s Rust and Cargo support is now generally available, providing dependency analysis and supply chain visibility for Rust projects.
helper-lib
Advanced tools

Extensive collection of Handlebars helpers.
For linting and testing this project uses Grunt ~0.4.1, but Grunt is not required to use the helpers. Check out the Getting Started guide to learn more about Grunt.
npm install helper-lib --save
Once helper-lib has been installed, it may be used within your application with the following JavaScript:
var handlebars = require('handlebars');
var helpers = require('helper-lib');
helpers.register(handlebars);
Now your handlebars instance will have access to the helpers.
Table of Contents
Handlebars.js ships with some built-in helpers, such as {{#each}}, {{#if}} and {{#unless}}. Here is how helpers work:
Handlebars.js is currently the default template library for assemble.
Contributions welcome! Please consider adding your own helpers to this library.
Handlebars accels over other templating libraries when it comes to creating your own custom helpers. Just register your function into Handlebars with the Handlebars.registerHelper method, and that helper will be available to any template you compile afterwards.
Handlebars allows two different kinds of helpers:
{{#each}}, {{#if}} and {{#unless}}. Custom block helpers are registered the same way as exptression helpers, but the difference is that Handlebars will pass the contents of the block compiled into a function to the helper.Embed code from given file
Parameters:
String|File : path to the file you want to embedString (optional): Optional second parameter to "force" a specific language to use fo syntax highlighting.Syntax: {{ embed [file] [syntax] }}
Helper also:
``` html) in the output..md|markdown|markd), the helper automatically converts any code fences inside the snippet their unicode equivalent (```)Example:
{{ embed 'src/test.json' }}
// Force highlighting as `javascript` instead of `json`
{{ embed 'src/test.json' 'javascript' }}
TODO...
Creates a "full" Travis CI link in markdown format.
Params: branch
Type: String
Usage: {{travis [branch]}}
Example using default: {{travis}}
# [helper-lib v2.0.0](https://github.com/assemble/helper-lib)[](https://travis-ci.org/assemble/helper-lib)
Example with branch: {{travis 'master'}}
# [helper-lib v2.0.0](https://github.com/assemble/helper-lib)[](https://travis-ci.org/assemble/helper-lib)
Creates a Travis CI link in markdown format.
Params: none
Usage: {{travis-badge}}
Example:
[](https://travis-ci.org/assemble/helper-lib)
A few convenience helpers that read data in YAML format, and do interesting things with the data. Well... they "do things" with the data. Anyway I guess only nerds like me find it interesting.
NOTE: These helpers will throw an error if the source files are not valid YAML format, using the following conventions:
A couple things to keep in mind about YAML:
Here is an example of the format to follow in your CHANGELOG file:
v0.1.2
date: "2014-04-09"
changes:
- The future sucks.
- This is my third and last commmit from the future.
v0.1.1
date: "2014-04-08"
changes:
- Second commit from the future.
- The future is more boring that I thought it would be.
v0.1.0
date: "2014-03-07"
changes:
- First commit... from the future. Yes!
Of coure, you are under no obligation to make your changelog entries as interesting as these, and you may record your entries at any point in whatever timeline you prefer, but whatever you write must be valid YAML when you do it.
The output will look like this:
* 2013-03-15 v0.1.2 Update README.md with documentation, examples.
* 2013-03-06 v0.1.0 First commit.
Output a formatted phone number Credit: Treehouse Blog
phoneNumber: 4444444444
{{formatPhoneNumber phoneNumber}}
Result:
(444) 444-4444
Include external files.
Pattern: {{include [name] [data]}}
Parameters:
[string] - The name or path of the file in which your template is defined. (Required)[int|string|collection] - Data you want to use inside the include.Data (collection): planet-express.json
[
"Professor Farnsworth",
"Fry",
"Bender"
]
Include (partial to be "included"): planet-express.hbs
{{sort this}}
Template:
<p>{{include "planet-express.hbs" data}}</p>
Result:
<p>Bender, Fry, Professor Farnsworth</p>
Why do this? The goal is to inspire other concepts that build from this one.
Use globbing patterns to embed content from specified file or files.
Parameters: String
Default: undefined
Examples:
{{glob 'src/files/*.md'}}
{{glob 'src/files/*.{txt,md}'}}
Example helper, copies file A to path B.
Parameters: String
Default: undefined
Example:
{{copy 'a.html' '../dir/b.txt'}}
Evaluate string A, and count the occurrences of string B within string A
Default: undefined
Parameters:
String A (required): The string to evaluateString B (required): The string to look for and count in "string A"{{occurrences "evaluate this string" "evaluate"}}
// Result
1
Replace spaces in string with hyphens.
Parameters: none
{{hyphenate "make this all hyphenated"}}
// Result
make-this-all-hyphenated
Same as hyphenate, but replaces dots in string with hyphens.
Parameters: none
{{dashify "make.this.all.hyphenated"}}
// Result
make-this-all-hyphenated
Turns a string to lowercase.
Parameters: none
{{lowercase "MAKE THIS ALL LOWERCASE"}}
// Result
make this all lowercase
Turns a string to uppercase. Opposite of {{lowercase}}.
Parameters: none
{{uppercase "make this all uppercase"}}
// Result
MAKE THIS ALL UPPERCASE
Capitalizes the first word in a string.
Parameters: none
{{capitalizeFirst "capitalize first word in this sentence"}}
// Result
Capitalize first word in this sentence
Capitalizes each word in a string.
Parameters: none
{{capitalizeEach "capitalize EACH word in this sentence"}}
// Result
Capitalize EACH Word In This Sentence
Capitalizes all words within a string. Taken from the templating library Walrus by Jeremy Ruppel.
Parameters: none
{{titleize "capitalize EACH word in this sentence"}}
// Result
Capitalize Each Word In This Sentence.
Capitalizes the first word of each sentence in a string and converts the rest of the sentence to lowercase.
Parameters: none
{{sentence "capitalize the FIRST word in each sentence. but make the OTHER words lowercase."}}
// Result
Capitalize the first word in each sentence. But make the other words lowercase.
Reverses a string.
Parameters: none
{{reverse "bender should NOT be allowed on TV."}}
// Result
.VT no dewolla eb TON dluohs redneb
Truncates a string given a specified length, providing a custom string to denote an omission.
Parameters:
int- The number of characters to keep (Required).string - A string to denote an omission (Optional).{{truncate "Bender should not be allowed on tv." 31 "..."}}
// Result
Bender should not be allowed...
Centers a string using non-breaking spaces.
Parameters: spaces: int - The number of spaces. (Required)
{{center "Bender should not be allowed on tv." 10}}
// Result:
| Bender should not be allowed on tv. |
Convert new lines (\r\n, \n\r, \r, \n) to line breaks
Parameters: none
{{nl2br <br>description}}
// Result:
<br>
Returns the first item in a collection.
Parameters: none
// Data
collection = [
'Amy Wong',
'Bender',
'Dr. Zoidberg',
'Fry',
'Hermes Conrad',
'Leela',
'Professor Farnsworth',
'Scruffy'
]
// Template
{{first collection}}
// Result:
Amy Wong
Use the first item in a collection inside a block.
Parameters: none
// Data
collection = [
'Amy Wong',
'Bender',
'Dr. Zoidberg',
'Fry',
'Hermes Conrad',
'Leela',
'Professor Farnsworth',
'Scruffy'
]
// Template
{{#withFirst collection}}
<p>{{this}} is smart.</p>
{{/withFirst}}
// Result:
<p>Amy Wong is smart.</p>
Returns the last item in a collection. Opposite of first.
Parameters: none
// Data
collection = [
'Amy Wong',
'Bender',
'Dr. Zoidberg',
'Fry',
'Hermes Conrad',
'Leela',
'Professor Farnsworth',
'Scruffy'
]
// Template
{{last collection}}
// Result:
Scruffy
Use the last item in a collection inside a block. Opposite of withFirst.
Parameters: none
// Data
collection = [
'Amy Wong',
'Bender',
'Dr. Zoidberg',
'Fry',
'Hermes Conrad',
'Leela',
'Professor Farnsworth',
'Scruffy'
]
// Template
{{#withLast collection}}
<p>{{this}} is lazy.</p>
{{/withLast}}
// Result:
<p>Scruffy is lazy.</p>
Returns all of the items in the collection after the specified count.
Parameters: count int - How many items to omit from the beginning. (Required)
// Date
collection = [
'Amy Wong',
'Bender',
'Dr. Zoidberg',
'Fry',
'Hermes Conrad',
'Leela',
'Professor Farnsworth',
'Scruffy'
]
// Template
{{after collection 5}}
// Result:
Leela, Professor Farnsworth, Scruffy
Use all of the items in the collection after the specified count inside a block.
Parameters: count int - How many items to omit from the beginning. (Required)
// Data
collection = [
'Amy Wong',
'Bender',
'Dr. Zoidberg',
'Fry',
'Hermes Conrad',
'Leela',
'Professor Farnsworth',
'Scruffy'
]
// Template
{{#withAfter collection 5}}
{{titleize this}}
{{/withAfter}}
// Result:
Leela Professor Farnsworth Scruffy
Returns all of the items in the collection before the specified count. Opposite of after.
Parameters: count int - How many items to omit from the end. (Required)
// Data
collection = [
'Amy Wong',
'Bender',
'Dr. Zoidberg',
'Fry',
'Hermes Conrad',
'Leela',
'Professor Farnsworth',
'Scruffy'
]
// Template
{{before collection 5}}
// Result:
Amy Wong, Bender, Dr. Zoidberg
Use all of the items in the collection before the specified count inside a block. Opposite of withAfter.
Parameters: count int - How many items to omit from the end. (Required)
// Data
collection = [
'Amy Wong',
'Bender',
'Dr. Zoidberg',
'Fry',
'Hermes Conrad',
'Leela',
'Professor Farnsworth',
'Scruffy'
]
// Template
{{#withBefore collection 5}}
{{reverse this}}
{{/withBefore}}
// Result:
gnoW ymA redneB grebdioZ .rD
Joins all elements of a collection into a string using a separator if specified.
Parameters: separator string - A string to use as a separator between the items. (Optional)
// Data
collection = [
'Amy Wong',
'Bender',
'Dr. Zoidberg',
'Fry',
'Hermes Conrad',
'Leela',
'Professor Farnsworth',
'Scruffy'
]
// Template
{{join collection " & "}}
// Result:
Amy Wong & Bender & Dr. Zoidberg & Fry & Hermes Conrad & Leela & Professor Farnsworth & Scruffy
Returns the collection sorted.
Parameters: none
// Data
collection = [
'Amy Wong',
'Bender',
'Dr. Zoidberg',
'Fry',
'Hermes Conrad',
'Leela',
'Professor Farnsworth',
'Scruffy'
]
// Template
{{sort collection}}
// Result:
Amy Wong, Bender, Dr. Zoidberg, Fry, Hermes Conrad, Leela, Professor Farnsworth, Scruffy
Uses the sorted collection inside the block.
Parameters: field string - String name of the field or property to sort by. (Optional)
// Data
collection = [
name: 'Leela'
deliveries: 8021,
name: 'Bender'
deliveries: 239,
name: 'Fry'
deliveries: -12
]
// Template
{{#withSort collection "deliveries"}}
{{name}}: {{deliveries}} <br>
{{/withSort}}
// Result:
Fry: -12
Bender: 239
Leela: 8021
Returns the length of the collection.
Parameters: none
// Data
collection = [
'Amy Wong',
'Bender',
'Dr. Zoidberg',
'Fry',
'Hermes Conrad',
'Leela',
'Professor Farnsworth',
'Scruffy'
]
// Template
{{length collection}}
// Result:
8
Conditionally render a block based on the length of a collection.
Parameters: length int - The value to test against. (Required)
// Data
collection = [
name: 'Leela'
deliveries: 8021,
name: 'Bender'
deliveries: 239,
name: 'Fry'
deliveries: -12
]
// Template
{{#lengthEqual collection 3}}
There are 3 people in Planet Express.
{{else}}
This is not Planet Express.
{{/lengthEqual}}
// Result:
There are 3 people in Planet Express.
Conditionally render a block if the collection is empty.
Parameters: none
// Data
collection = []
// Template
{{#empty collection}}
Good news everyone!
{{else}}
Bad news everyone!
{{/empty}}
// Result:
Good news everyone!
Conditionally render a block if the collection isn't empty. Opposite of empty
Parameters: none
// Data
collection = ['Professor Farnsworth']
// Templates
{{#any collection}}
Good news everyone!
{{else}}
Bad news everyone!
{{/any}}
// Result:
Good news everyone!
Conditionally render a block if a specified value is in the collection.
Parameters: value string|int - A value to test against. (Required)
// Data
collection = ['Professor Farnsworth', 'Fry', 'Bender']
// Templates
{{#inArray collection "Fry"}}
I'm walking on sunshine!
{{else}}
I'm walking on darkness.
{{/any}}
// Result:
I'm walking on sunshine!
Current implementation of the default Handlebars loop helper {{#each}} adding index (0-based index) to the loop context.
Parameters: none
// Data
collection = ['Professor Farnsworth', 'Fry', 'Bender']
// Templates
{{#eachIndex collection}}
{{this}} is {{index}}
{{/eachIndex}}
// Result:
Professor Farnsworth is 0, Fry is 1, Bender is 2
Loop through an objects properties
Parameters: none
// Data
TODO...
// Templates
{{#eachProperty object}}
{{property}}: {{value}}<br/>
{{/eachProperty }}
// Result
TODO...
Returns the sum of two numbers.
Parameters: value int - The number to add to the expression. (Required)
// Data
value = 5
// Template
{{add value 5}}
// Result:
10
Returns the difference of two numbers. Opposite of add
Parameters: value int - The number to subtract from the expression. (Required)_
// Data
value = 5
// Template
{{subtract value 5}}
// Result:
0
Returns the division of two numbers.
Parameters: value int - The number to divide the expression. (Required)
// Data
value = 5
// Template
{{divide value 5}}
// Result:
1
Returns the multiplication of two numbers.
Parameters: value int - The number to multiply the expression. (Required)
// Data
value = 5
// Template
{{multiply value 5}}
// Result:
25
Returns the value rounded down to the nearest integer.
Parameters: none
// Data
value = 5.6
// Template
{{floor value}}
// Result:
5
Returns the value rounded up to the nearest integer.
Parameters: none
// Data
value = 5.6
// Template
{{ceil value}}
// Result:
6
Returns the value rounded to the nearest integer.
Parameters: none
// Data
value = 5.69
// Template
{{round value}}
// Result:
6
Returns the sum of multiple numbers. Similar to {{#add}} block helper but accepts multiple arguments.
Parameters: none
// Data
value = {
a: 1,
b: 2,
c: 3
}
// Template
{{sum value.a value.b value.c}}
// Result:
6
Returns exactly digits after the decimal place. The number is rounded if necessary, and the fractional part is padded with zeros if necessary so that it has the specified length.
Parameters: digits int - The number of digits to appear after the decimal point. (Optional)
// Data
value = 5.53231
// Template
{{toFixed value 3}}
// Result:
5.532
Returns the number in fixed-point or exponential notation rounded to precision significant digits.
Parameters: precision int - The number of digits. If omitted, it returns the entire number (without any formatting). (Optional)
// Data
value = 555.322
// Template
{{toPrecision value 4}}
// Result:
555.3
Returns the number in exponential notation with one digit before the decimal point, rounded to fractions digits after the decimal point.
Parameters: fractions int - An integer specifying the number of digits after the decimal point. (Optional)
// Data
value = 5
// Template
{{toExponential value 5}}
// Result:
5.00000e+0
Returns an integer.
Parameters: none
// Data
value = '22.2abc'
// Template
{{toInt value}}
// Result:
22
Returns a floating point number.
Parameters: none
// Data
value = '22.2abc'
// Template
{{toFloat value}}
// Result:
22.2
Returns the number in abbreviation formats based on a value. The number is rounded to a particular decimal place.
Parameters: digits int - The number of digits to appear after the decimal point. (Optional)
Default: 2
// Data
value = 123456789
// Template
{{toAbbr value}}
// Result:
123.457m
Adds commas to a number.
Parameters: none
// Data
value = 2222222
// Template
{{addCommas value}}
// Result:
2,222,222
Conditionally render a block if the condition is true (if x = y).
Parameters: string|int (the value to test against)
Default: undefined
Example #1:
// Data
---
number = 5
---
// Template
{{#is number 5}}
Kiss my shiny metal ass!
{{else}}
Never mind :(
{{/is}}
// Result:
Kiss my shiny metal ass!
Example #2:
If you are using Assemble, data from YAML front matter or any specified JSON and/or YAML source files will get passed through to the context in your templates.
--- # YAML Front Matter
page:
title: About Us
---
{{#is page.title "home"}}
<h1> About Us </h1>
{{else}}
Never mind :(
{{/is}}
Result:
<h1> About Us </h1>
Same as is, consider consolidating
Conditionally render a block if the condition is true (If x = y).
Parameters: none
{{#if_eq x compare=y}} ... {{/if_eq}}
Conditionally render a block if the condition is false. Opposite of is.
Parameters: value string|int - the value to test against.
// Data
number = 5
// Template
{{#isnt number 5}}
Kiss my shiny metal ass!
{{else}}
Never mind :(
{{/isnt}}
// Result:
Never mind :(
Conditionally render a block if one of the values is truthy.
Parameters: values string|int - the values to test against.
great = no
magnificent = true
// Template
{{#or great magnificent}}
Kiss my shiny metal ass!
{{else}}
Never mind :(
{{/or}}
// Result:
Kiss my shiny metal ass!
Conditionally render a block if both values are truthy.
Parameters: values string|int - the values to test against.
// Data
great = true
magnificent = true
// Template
{{#and great magnificent}}
Kiss my shiny metal ass!
{{else}}
Never mind :(
{{/and}}
// Result:
Kiss my shiny metal ass!
Same as isnt, consider consolidating
Conditionally render a block if the condition is false (Unless x = y). Opposite of is.
Parameters: none
{{#unless_eq x compare=y}} ... {{/unless_eq}}
Conditionally render a block if the value is greater than a given number (If x > y).
Parameters: none
{{#if_gt x compare=y}} ... {{/if_gt}}
Same as if_gt, consider consolidating
Conditionally render a block if the value is greater than a given number (If x > y).
Parameters: value string|int - the value to test against.
// Data
number = 5
// Template
{{#gt number 8}}
Kiss my shiny metal ass!
{{else}}
Never mind :(
{{/gt}}
// Result:
Never mind :(
Unless greater than (Unless x > y)
Parameters: none
{{#unless_gt x compare=y}} ... {{/unless_gt}}
Conditionally render a block if the value is greater or equal than a given number (If x >= y).
Parameters: none
{{#if_gteq x compare=y}} ... {{/if_gteq}}
Same as if_gteq, consider consolidating
Conditionally render a block if the value is greater or equal than a given number (If x >= y).
Parameters: value string|int - the value to test against.
number = 5
// Template
{{#gte number 5}}
Kiss my shiny metal ass!
{{else}}
Never mind :(
{{/gte}}
// Result:
Kiss my shiny metal ass!
Render block, unless given value is greater than or equal to.
Parameters: none
Unless x >= y
{{#unless_gteq x compare=y}} ... {{/unless_gteq}}
Conditionally render a block if the value is less than a given number. Opposite of gt.
Parameters: value string|int - the value to test against.
number = 5
{{#lt number 3}}
Kiss my shiny metal ass!
{{else}}
Never mind :(
{{/lt}}
// Result:
Never mind :(
Conditionally render a block if the value is less or equal than a given number. Opposite of gte.
Parameters: value string|int - the value to test against.
number = 5
// Template
{{#lte number 5}}
Kiss my shiny metal ass!
{{else}}
Never mind :(
{{/lte}}
// Result:
Kiss my shiny metal ass!
Render block, unless value is less than a given number (Unless x < y)
Parameters: none
{{#unless_lt x compare=y}} ... {{/unless_lt}}
Render block, unless value is less than or equal to a given number (Unless x <= y)
Parameters: none
{{#unless_lteq x compare=y}} ... {{/unless_lteq}}
Formats a date into a string given a format. Accepts any value that can be passed to new Date(). This helper is a port of the formatDate-js library by Michael Baldry.
Parameters: format string, required
The format string, according to these tokens: strftime
// Data
date = new Date()
// Template
{{formatDate date "%m/%d/%Y"}}
{{formatDate date "%I:%M%p"}}
{{formatDate date "%F"}}
{{formatDate date "%Y%m%dT%H%M%S%z"}}
// Result:
07/26/2012
11:38PM
2012-07-26
20120726T233805-0004
Returns the current date.
Parameters: format string - The format string, according to these tokens: http://www.ruby-doc.org/core-1.9.3/Time.html#method-i-strftime (Optional)
// Template
{{now}}
{{now "%m/%d/%Y"}}
// Result:
Thu Jul 26 2012 23:41:02 GMT-0400 (AST)
07/26/2012
Returns a human-readable time phrase from the given date.
Parameters: none
// Data
date = 'Thu Jul 22 2012 23:41:02 GMT-0400 (AST)'
// Template
{{timeago date}}
// Result:
4 days ago
Returns the plural or singular form of a word based on a count.
Parameters:
string - The singular form of the word. (Required)string - The plural form of the word. (Required)boolean - whether or not to include the count before the word. (Optional)// Data
enemies = 0
friends = 1
// Template
{{inflect enemies "enemy" "enemies"}}
{{inflect friends "friend" "friends" true}}
// Result:
enemies
1 friend
#### ordinalize
_Turns a number into an ordinal string. Taken from the templating library [Walrus](https://github.com/jeremyruppel/walrus) by [Jeremy Ruppel](https://github.com/jeremyruppel)._
<br>Parameters: `none`
``` html
// Template
{{ordinalize 3}}
{{ordinalize 1}}
{{ordinalize 22}}
// Result:
3rd
1st
22nd
Embed public GitHub Gists by adding only the Id of the Gist. The helper also accepts an optional second parameter for targeting a specific file on the Gist..
Parameters: String
Default: undefined
Usage: {{ gist [id] }}
Example:
{{gist '5193239'}}
Output:
<script src="https://gist.github.com/5193239.js"></script>
Create a blockquote
Outputs a string with a given attribution as a quote
{{#blockquote '@doowb' 'http://github.com/source/for/your/quote' 'This is the title' }}
This is your quote.
{{/blockquote}}
Output:
<blockquote>
<p>This is your quote.</p>
<footer>
<strong>@doowb</strong>
<cite>
<a href="http://github.com/source/for/your/quote">This is the title</a>
</cite>
</footer>
</blockquote>
Iterates through an array, letting the contents know whether to add an even or odd row.
Parameters:
array to iterate over,string: CSS class name for even rowsstring: CSS class name for odd rowsCredit: treehouse blog
Usage:
{{#stripes myArray "even" "odd"}}
<div class="{{stripeClass}}">
... code for the row ...
</div>
{{else}}
<em>There aren't any people.</em>
{{/stripes}}
Iterates through an array, letting the contents know whether a timeline entry belongs in the left or right column.
Parameters:
array to iterate over,string: CSS class name for left columnsstring: CSS class name for right columnsCredit: by @jonschlinkert, and based on striped helper from treehouse blog
Usage:
<div class="timeline">
{{#timeline myArray "left" "right"}}
<div class="{{columnClass}}">
{{> entry}}
</div>
{{else}}
<em>There aren't any entries.</em>
{{/timeline}}
</div>
Creates an unordered list.
Parameters: Hash|HTML attributes, Optional
HTML attributes to use on the ul element.
// Data
collection = [
name: 'Leela'
deliveries: 8021,
name: 'Bender'
deliveries: 239,
name: 'Fry'
deliveries: 1
]
Template:
{{#ul collection class="deliveries-list"}}
{{name}} - {{inflect deliveries "delivery" "deliveries" true}}
{{/ul}}
// Output:
<ul class="deliveries-list">
<li> Leela - 8021 deliveries </li>
<li> Bender - 239 deliveries </li>
<li> Fry - 1 delivery </li>
</ul>
Same as the ul helper but creates and ordered list. Returns <br> tags based on a count.
Parameters: Hash, HTML attributes, Optional
HTML attributes to use on the ol element.
// Data
collection = [
name: 'Leela'
deliveries: 8021,
name: 'Bender'
deliveries: 239,
name: 'Fry'
deliveries: 1
]
Template:
{{#ol collection class="deliveries-list"}}
{{name}} - {{inflect deliveries "delivery" "deliveries" true}}
{{/ol}}
// Output:
<ol class="deliveries-list">
<li> Leela - 8021 deliveries </li>
<li> Bender - 239 deliveries </li>
<li> Fry - 1 delivery </li>
</ol>
Renders <br> elements in the output, based on the number given as a parameter. Not really recommended for general use, but it's here if you need it.
Parameters: Integer|Count, Optional
The number of br elements to render.
template.hbs
{{br 5}}
renders to:
`<br><br><br><br><br>`
Simple console.log()
Parameters: none
// Template
{{log "Hi console :)"}}
// Result:
Hi console :)
Simple console.debug() that shows the current context.
Parameters: none
// Data
collection = [
name: 'Leela'
deliveries: 8021,
name: 'Bender'
deliveries: 239,
name: 'Fry'
deliveries: 1
]
// Template
{{#withFirst collection}}
{{debug name}}
{{/withFirst}}
// Result:
Context: { deliveries: 8021, name: "Leela" }
Value: Leela
Return a unique, JSON-formatted array of all file or directory paths that match the given globbing pattern(s)
Parameters: String
Default: undefined
Example:
{{expandJSON './src/**/*.md'}}
// returns
[
"./src/content/blockquotes.md",
"./src/content/chapters/01-getting-started.md",
"./src/content/chapters/02-language-features.md",
"./src/content/chapters/03-advanced-materials.md",
"./src/content/code.md",
"./src/content/emphasis.md",
"./src/content/headings.md",
"./src/content/images.md",
"./src/content/links.md",
"./src/content/lists.md",
"./src/content/markdown-here.md",
"./src/content/paragraphs.md",
"./src/content/post.md",
"./src/content/reference-links.md",
"./src/content/reference.md",
"./src/content/tables.md",
"./src/content/test.md"
]
Return a unique, YAML-formatted array of all file or directory paths that match the given globbing pattern(s)
Parameters: String
Default: undefined
Example:
{{expandYAML './src/**/*.md'}}
// returns
- "./src/content/blockquotes.md"
- "./src/content/chapters/01-getting-started.md"
- "./src/content/chapters/02-language-features.md"
- "./src/content/chapters/03-advanced-materials.md"
- "./src/content/code.md"
- "./src/content/emphasis.md"
- "./src/content/headings.md"
- "./src/content/images.md"
- "./src/content/links.md"
- "./src/content/lists.md"
- "./src/content/markdown-here.md"
- "./src/content/paragraphs.md"
- "./src/content/post.md"
- "./src/content/reference-links.md"
- "./src/content/reference.md"
- "./src/content/tables.md"
- "./src/content/test.md"
Provides a default or fallback value if a value doesn't exist.
Parameters: defaultValue string|int - The default value to use. title = ''
// Template
{{default title "No title available."}}
// Result:
No title available.
In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code using Grunt.
Many of these helpers come from the following repos:
Copyright 2013 Assemble
Authored by assemble
This file was generated using Grunt and assemble on Sun May 26 2013 10:24:06.
FAQs
Deprecated. Please use [handlebars-helpers](https://github.com/assemble/handlebars-helpers) instead.
The npm package helper-lib receives a total of 51 weekly downloads. As such, helper-lib popularity was classified as not popular.
We found that helper-lib demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Product
Socket’s Rust and Cargo support is now generally available, providing dependency analysis and supply chain visibility for Rust projects.

Security News
Chrome 144 introduces the Temporal API, a modern approach to date and time handling designed to fix long-standing issues with JavaScript’s Date object.

Research
Five coordinated Chrome extensions enable session hijacking and block security controls across enterprise HR and ERP platforms.