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
  • Basic syntax
  • Scoping
  • ID
  1. Template Syntax

Helper References

In Squirrelly, a reference is a single value that's passed in as an option to the template. There are two types of references, global references and helper references.

A helper reference is a reference that points to data created by a helper. For example, when looping through an object using the foreach helper

Basic syntax

<p>This is a helper reference: {{@stuff}}</p>

Prefix a helper reference with @.

Helper references are always in the scope of its parent helper.

Scoping

To access the helper references of an outside helper, you can use scoping. Example:

{{helper1(parameters)}}
Do this
{{helper2(parameters)}}
This is a helper ref from helper2: {{@someref}}
This is a helper ref from helper1: {{@../someref}}
{{/helper2}}
{{/helper1}}

ID

If you have many layers of nestedness, it can be easier to use ID's instead of scoping.

{{helper1(parameters) someID}}
Do this
{{helper2(parameters)}}
This is a helper ref from helper2: {{@someref}}
This is a helper ref from helper1: {{@someID:someref}}
{{/helper2}}
{{/helper1}}
PreviousGlobal ReferencesNextFilters

Last updated 5 years ago