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
  1. Template Syntax

Global 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.

Basic syntax:

<p>This is a global reference: {{myname}}</p>

Put a global reference between the opening and closing delimeters (by default {{and }}.

Global references are always in the global scope, and can be written anywhere in your code. Since Squirrelly templates parse into JavaScript, you can write a reference like this: <p>This is the child of an object: {{user.lastName}}</p>

or like this:

<p>This is the child of an object: {{user['lastName']}}</p>.

There can be spaces after the beginning bracket and before the closing bracket, but any reference that doesn't point to an actual value or is an invalid expression, like{{hi people}} (notice the space) will make your code break!

PreviousThe BasicsNextHelper References

Last updated 5 years ago