DocumentGenerator icon

DocumentGenerator

Render data using a Handlebars template

Overview

This node renders text output by applying Handlebars templates to input data items. It supports rendering each input item individually or all items together using a single template. The node can use either a direct template string or fetch a template from a URL. This is useful for generating customized documents, emails, reports, or any text-based content dynamically based on incoming data.

Common scenarios include:

  • Generating personalized email bodies for multiple recipients.
  • Creating formatted reports or summaries from datasets.
  • Rendering HTML or other markup templates with dynamic content.

Properties

Name Meaning
Render All Items with One Template Whether to render all input items using one combined template (with syntax like {{#each items}}{{columnname}}{{/each}}). If false, each item is rendered separately with its own template.
Use a Template String Choose whether to provide the template as a direct string or load it from a URL.
Template String The Handlebars template string used for rendering when "Use a Template String" is true. Supports full Handlebars syntax.
Template URL The URL to fetch the Handlebars template from when "Use a Template String" is false.
Define a Custom Output Key Whether to save the rendered output under a custom property name instead of the default "text".
Output Key The custom property name where the rendered text will be saved if "Define a Custom Output Key" is true.

Output

The node outputs JSON objects containing the rendered text under a property key:

  • By default, the rendered text is stored in the "text" property.
  • If a custom output key is defined, the rendered text is stored under that specified property name.
  • When rendering all items with one template, the output contains a single item with the combined rendered result.
  • When rendering each item individually, the output contains one item per input, each with its own rendered text.

No binary data output is produced by this node.

Dependencies

  • Uses the Handlebars templating engine (via the @jaredwray/fumanchu package) for compiling and rendering templates.
  • If using a template URL, requires network access to fetch the template via an HTTP request.
  • No special credentials are required unless the template URL requires authentication, which would need to be handled externally.

Troubleshooting

  • Empty or incorrect output: Ensure the template syntax matches Handlebars standards and references correct input data fields.
  • Template URL fetch failure: Verify the URL is accessible and returns valid template content. Network issues or invalid URLs will cause errors.
  • Rendering all items with one template: The template must use the items array context properly (e.g., {{#each items}}{{fieldName}}{{/each}}) to access all input data.
  • Custom output key not appearing: Confirm that "Define a Custom Output Key" is enabled and the output key is set correctly.
  • Unhandled exceptions: Check that input data is well-formed JSON and that the template does not contain unsupported expressions.

Links and References

Discussion