(template: string): string
(arguments: {template: string, on: object}): stringThe _nunjucks hydrates a Nunjucks template.
If called with a string argument, the template variables are the values in state. Otherwise template variables can be specified using the on argument.
Arguments
string
The template to hydrate. The template variables used are the values in state
object
template: string: The template to hydrate.on: object: The template variables to use when hydrating the template.
Examples
Populate a template from values in state:
_nunjucks: Hello {{ name }}Returns: "Hello Steven" if the value of name in state is "Steven".
Populate a markdown template with different values:
Assuming get_items returns:
- name: Coca Cola
description: The original.
- name: Pepsi
description: The same but different._nunjucks:
template: |
### {{ title }}
{% for item in item_list %}
- {{ item.name }}: {{ item.description }}
{% endfor %}
on:
title: Soft drinks
items:
_request: get_itemsReturns:
### Soft drinks
- Coca Cola: The original.
- Pepsi: The same but different.