render

Renders a template using the current local variables, unless a context thing is provided.

This function does not generate a change, unless the template code itself modifies stored data.

Function

template.render([context])

Arguments

Argument Type Description
context thing (optional) A thing containing the variables to use when evaluating the template. Defaults to the current local variables if omitted.

Return value

Returns the rendered str value.

Example

This code shows how to use render() with local variables and with a custom context:

tpl = template('Hello {name}!');

name = 'Alice';
a = tpl.render();

b = tpl.render({name: 'Bob'});

[a, b];

Return value in JSON format

[
    "Hello Alice!",
    "Hello Bob!"
]