Skip to main content
Deno 2 is finally here 🎉️
Learn more
Module

x/eta/browser.ts>compile

Embedded JS template engine for Node, Deno, and the browser. Lighweight, fast, and pluggable. Written in TypeScript
Go to Latest
function compile
import { compile } from "https://deno.land/x/eta@v2.2.0/browser.ts";

Takes a template string and returns a template function that can be called with (data, config, [cb])

Parameters

str: string
  • The template string
optional
config: PartialConfig
  • A custom configuration object (optional)

Example

let compiledFn = eta.compile("Hi <%= it.user %>")
// function anonymous()
let compiledFnStr = compiledFn.toString()
// "function anonymous(it,E,cb\n) {\nvar tR='',include=E.include.bind(E),includeFile=E.includeFile.bind(E);tR+='Hi ';tR+=E.e(it.user);if(cb){cb(null,tR)} return tR\n}"

Returns

TemplateFunction