Similarly to many other libraries, Squirrelly allows you to customize its behavior via options.

TypeDoc doc page

List of options

asyncWhether to generate async templatesbooleanfalseYes
autoEscapeWhether to automatically XML-escapebooleanYes
autoTrimConfigure automatic whitespace trimmingautoTrim[false, "nl"]Yes
cacheCache templates by name or filenamebooleanYes
defaultFilterPass all interpolates through a function`falseFunction`false
filenameAbsolute filepath of template (for caching)stringundefinedNo
lFunction that returns helpers. See lFunctiondefaultConfig.lYes
nameTemplate name (for caching)stringundefinedNo
pluginsPlugins objectpluginsdefaultConfig.pluginsYes
rootBase filepath. Defaults to "\" internallystringundefinedNo
storageObject containing templates, helpers, filtersstoragedefaultConfig.storageYes
tagsTemplate delimiters. CAVEATS[string, string]["{{", "}}"]Yes
useWithUse with(){} to have data scope as globalbooleanundefinedNo
varNameName of data objectstring"it"Yes
view cacheOverrides cachebooleanundefinedNo
viewsAbsolute filepath to views directorystringundefinedNo

Delimiter Caveats

Closing delimeters (like {{) can't have any of (, ), |, or =>.

Delimeters must be RegExp-escaped.


autoTrim controls whitespace trimming.


"nl" | "slurp" | boolean | ["nl" | "slurp" | boolean, "nl" | "slurp" | boolean]


  • "nl" trims first character
  • "slurp" trims all leading/trailing whitespace
  • true is equivalent to "slurp"

When an array is passed, Squirrelly uses the equivalent options on the left or right side of the string


l is a function that is used inside template functions to fetch filters and helpers.


(container: "H" | "F", name: string) => Function


function (container, name) {
if (container === 'H') {
var hRet = helpers.get(name)
if (hRet) {
return hRet
} else {
throw SqrlErr("Can't find helper '" + name + "'")
} else if (container === 'F') {
var fRet = filters.get(name)
if (fRet) {
return fRet
} else {
throw SqrlErr("Can't find filter '" + name + "'")


plugins is an object with the following properties:

processASTList of functions that manipulate Squirrelly syntax treeArray<object>[]
processFnStringList of functions that manipulate Squirrelly template functionArray<object>[]


storage points to helpers, native helpers, filters, and templates. It's an object with the following properties:

filtersFilters cacheCacher<FilterFunction>Sqrl.filters
helpersHelpers cacheCacher<HelperFunction>Sqrl.helpers
nativeHelpersNative helpers cacheCacher<NativeHelperFunction>Sqrl.nativeHelpers
templatesTemplates cacheCacher<TemplateFunction>Sqrl.templates

You only need to modify it if you want to create environments with different caches.


Sqrl.defaultConfig returns the default configuration. See above.


getConfig takes some config options and merges them with the default. It optionally takes a third parameter, which it merges with the default first.

High-level APIs like render and compile call getConfig internally, but you should call lower-level APIs (like compileToString) with a valid config object, which you can get from this function.


TypeDoc doc page


Sqrl.compileToString(myTemplate, Sqrl.getConfig({ tags: ["<%", "%>"] }));