Built-in Helpers

Builtin helpers are helpers that come as part of the Squirrelly library. They can always be overwritten if desired, but they provide simple, no-setup logic within templates.

if/else

{{if(options.somevalue === 1)}}
Display this
{{#else}}
Display this
{{/if}}

each

{{each(options.somearray)}}
Display this
The current array element is {{@this}}
The current index is {{@index}}
{{/each}}

Helper References:

  • this: the current array element
  • index: the index of the array element

foreach

{{foreach(options.someobject)}}
This loops over each of an objects keys and values.
The value of the current child is {{@this}}
The current key is {{@key}}

Helper References:

  • this: the value of the current object child
  • key: the key of the current child

log

{{log("The value of options.arr is: " + options.arr)/}}
note

The log helper is a self-closing, native helper. It's turned into this code:

console.log('The value of options.arr is: ' + options.arr)

It can be extremely helpful for debugging.

tags

{{tags(--,--)/}}
--somevalue--
note

Setting custom tags can be really helpful when writing in a language such as LaTek.

js

{{js(options.newvalue = options.oldvalue + 983 * 2)/}}
{{newvalue}}