Skip to main content
Module

x/eta/mod.ts>render

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

Render a template

If template is a string, Eta will compile it to a function and then call it with the provided data. If template is a template function, Eta will call it with the provided data.

If config.async is false, Eta will return the rendered template.

If config.async is true and there's a callback function, Eta will call the callback with (err, renderedTemplate). If config.async is true and there's not a callback function, Eta will return a Promise that resolves to the rendered template.

If config.cache is true and config has a name or filename property, Eta will cache the template on the first render and use the cached template for all subsequent renders.

Parameters

template: string | TemplateFunction

Template string or template function

data: object

Data to render the template with

config: PartialAsyncConfig

Optional config options

cb: CallbackFn

Callback function

Render a template

If template is a string, Eta will compile it to a function and then call it with the provided data. If template is a template function, Eta will call it with the provided data.

If config.async is false, Eta will return the rendered template.

If config.async is true and there's a callback function, Eta will call the callback with (err, renderedTemplate). If config.async is true and there's not a callback function, Eta will return a Promise that resolves to the rendered template.

If config.cache is true and config has a name or filename property, Eta will cache the template on the first render and use the cached template for all subsequent renders.

Parameters

template: string | TemplateFunction

Template string or template function

data: object

Data to render the template with

config: PartialAsyncConfig

Optional config options

Returns

Promise<string>

Render a template

If template is a string, Eta will compile it to a function and then call it with the provided data. If template is a template function, Eta will call it with the provided data.

If config.async is false, Eta will return the rendered template.

If config.async is true and there's a callback function, Eta will call the callback with (err, renderedTemplate). If config.async is true and there's not a callback function, Eta will return a Promise that resolves to the rendered template.

If config.cache is true and config has a name or filename property, Eta will cache the template on the first render and use the cached template for all subsequent renders.

Parameters

template: string | TemplateFunction

Template string or template function

data: object

Data to render the template with

optional
config: PartialConfig

Optional config options

Returns

string

Render a template

If template is a string, Eta will compile it to a function and then call it with the provided data. If template is a template function, Eta will call it with the provided data.

If config.async is false, Eta will return the rendered template.

If config.async is true and there's a callback function, Eta will call the callback with (err, renderedTemplate). If config.async is true and there's not a callback function, Eta will return a Promise that resolves to the rendered template.

If config.cache is true and config has a name or filename property, Eta will cache the template on the first render and use the cached template for all subsequent renders.

Parameters

template: string | TemplateFunction

Template string or template function

data: object

Data to render the template with

optional
config: PartialConfig

Optional config options

optional
cb: CallbackFn

Callback function

Returns

string | Promise<string> | void