Similarly to many other libraries, Eta 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
eXML-escaping functionFunctionconfig.eYes
filenameAbsolute filepath of template (for caching)stringundefinedNo
nameTemplate name (for caching)stringundefinedNo
pluginsPlugins arraypluginsconfig.pluginsYes
rootBase filepath. Defaults to "\" internallystringundefinedNo
templatesObject containing templatesCacher<TemplateFunction>config.templatesYes
tagsTemplate delimiters[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

Delimeters must be RegExp-escaped.


autoTrim controls whitespace trimming.


"nl" | "slurp" | false | ["nl" | "slurp" | false, "nl" | "slurp" | false]


  • "nl" trims a leading or trailing newline
  • "slurp" trims all leading/trailing whitespace
  • true is equivalent to "slurp"

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


plugins is an array of objects, each with the following properties:

processASTFunction that manipulates Eta syntax treeFunction
processFnStringFunction that manipulates Eta template functionFunction


Eta.config returns Eta's base ("global") 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


Eta.compileToString(myTemplate, Eta.getConfig({ tags: ["{{", "}}"] }))