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.
template.render([context])
| 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. |
Returns the rendered str value.
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!"
]