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
  • Simple Template:
  • Conditionals:
  • Loops

Overview

NextFAQ

Last updated 5 years ago

Squirrelly is a template engine written in JavaScript.

With Squirrelly, you can write templates that are blazing fast and can be rendered in milliseconds, server-side or client-side.

Squirrelly doesn't just limit you to HTML--you can use it with any language, and custom delimeters make it so there aren't parsing errors. It's also tiny (~2.5 KB gzipped), has 0 dependencies, and is blazing fast.

Did you know that Squirrelly is consistently faster than most other template engines, according to benchmarks?

Simple Template:

var myTemplate = "<p>My favorite kind of cake is: {{favoriteCake}}</p>"

Sqrl.Render(myTemplate, {favoriteCake: 'Chocolate!'})
// Returns: '<p>My favorite kind of cake is: Chocolate!</p>

Conditionals:

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

Loops

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