Squirrelly
Get StartedTemplate SyntaxAPICommunity
7.x.x
7.x.x
  • Overview
  • FAQ
  • Demo
  • Performance
  • Changelog
  • Getting Started
    • Installation
    • Your First Template
    • Why Squirrelly?
    • What's a template engine?
  • Template Syntax
    • The Basics
    • Global References
    • Helper References
    • Filters
    • Helpers
    • Self-Closing Helpers
    • Native Helpers
    • Setting custom tags
    • Partials
    • Built-in Helpers
  • API
    • API Overview
    • Compile
    • Render
    • renderFile
    • load
    • defineFilter
    • setDefaultFilters
    • autoEscaping
    • defineHelper
    • defineNativeHelper
    • definePartial
    • defaultTags
  • Recipes
    • Squirrelly with ExpressJS
  • Guides
    • Generating Badges with Squirrelly
Powered by GitBook
On this page
  • if/else
  • each
  • Helper References:
  • foreach
  • Helper References:
  • log
  • tags
  • js
  1. Template Syntax

Built-in Helpers

A list of all Squirrelly's built-in native helpers..

if/else

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

each

each loops over an array.

{{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 loops over an object

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

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)/}}

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);

The log helper can be extremely helpful for debugging.

tags

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

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

js

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

Last updated 5 years ago