npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

n8n-nodes-document-generator

v1.0.9

Published

This node creates dynamic content for documents or emails with Handlebars templates

Downloads

5,340

Readme

Banner image

n8n-nodes-document-generator

This is an n8n community node. It helps you to create:

  • One dynamic content per all input items.
  • One dynamic content per input item.

If you have any questions or remarks please contact me.

n8n is a fair-code licensed workflow automation platform.

TL;DR

Don't want to read? Import the sample workflow Generate dynamic contents for EMAILS or HTML pages to test this node with random samples. Generate dynamic contents for EMAILS or HTML pages

Installation

Follow the installation guide in the n8n community nodes documentation.

Compatibility

This node was developed and tested with version 0.193.5 of n8n.

Dependencies

If you install this node, n8n will install automatically the next extra npm packages:

  • handlebars: required to work with Handlebars templates

Usage

The node can solve multiple use cases when creating content like:

  • Email generation (HTML or TEXT)
  • Static HTML pages
  • WordPress posts
  • Telegram/Slack messages

The sky is your limit!

Just follow the next samples to create your dynamic content and forget to use SET, FUNCTION, or FUNCTION ITEM nodes.

All input items in one template

Cases

  • You want to send a list of recent news about n8n.
  • You want to send the list of the customers created in the last hour in your database.

Template

Supposing that you have a customer list in JSON:

[
	{
		"email": "[email protected]",
		"name": "Miquel"
	},
	{
		"email": "[email protected]",
		"name": "Contact"
	}
]

You need to use this template:

<ul id="customer_list">
  {{#each items}}
  <li>{{name}}: {{email}}</li>
  {{/each}}
</ul>

And you will get the next output to send by email in HTML format:

<ul id="customer_list">
<li>Miquel: [email protected]</li>
<li>Contact: [email protected]</li>
</ul>

Property items is always mandatory to iterate over all items.

One input item per template

Cases

  • You have an invoice with header and lines and you want to send it by email.

Template

If you have one item/invoice with this JSON:

{
	"date": "2022-01-12",
	"to": "N8n hackers",
	"address": "Granollers, Spain",
	"total": 133.10,
	"lines": [
		{
			"description": "Create a node to render items in handlebar templates",
			"quantity": 1,
			"amount": 100,
			"vat": 21,
			"total": 121
		},
		{
			"description": "Test a node to render items in handlebar templates",
			"quantity": 1,
			"amount": 10,
			"vat": 2.10,
			"total": 12.1
		}
	]
}

You need to use this template:

Date: {{date}}
To: {{to}}
Address: {{address}}
Details:
{{#each lines}}
- "{{description}}" x {{quantity}} = {{amount}}€ + {{vat}}€ = {{total}}€
{{/each}}
Total invoice: {{total}}€

And you will get the next output to send by email in TEXT format:

Date: 2022-01-12
To: N8n hackers
Address: Granollers, Spain
Details:
- "Create a node to render items in handlebar templates" x 1 = 100€ + 21€ = 121€
- "Test a node to render items in handlebar templates" x 1 = 10€ + 2.10€ = 12.10€
Total invoice: 133.10€

I recommend using this method if you want to send multiple invoices.

Doubts about templates syntax

Please, check the official page to review all the existing expressions in Handlebars.

Another way to try it out

N8N documentation on custom nodes

Clone the n8n-nodes-document-generator repository and execute:

# Use v20.12.2 = lts/iron
nvm use lts/iron

# Install dependencies
npm install

# Build the code
npm run build

# "Publish" the package locally
npm link

Create an N8N installation and add the n8n-nodes-document-generator to it:

# Ensure that custom nodes directory exists in your .n8n
mkdir ~/.n8n/custom

# Init npm packages (intro to all questions)
cd ~/.n8n/custom && npm init

# "Install" the locally published module
npm link n8n-nodes-document-generator

# Start n8n
n8n start

Contribution

To make this node even better, please let us know, how you use it. Commits are always welcome.

Issues

If you have any issues, please let us know on GitHub.

About

Nodes by n8nhackers.com. For productive use and consulting on this, contact us please.

Special thanks to N8n nodemation workflow automation by Jan Oberhauser.

License

MIT