frinyvonnick / node-html-to-image

A Node.js module that generates images from HTML
https://www.npmjs.com/package/node-html-to-image
Apache License 2.0
831 stars 125 forks source link

Should Handlebars be a dependency? #47

Open bentorkington opened 4 years ago

bentorkington commented 4 years ago

Since not all users will necessarily use templating, and those that do can simply pass the output from Handlebars (or potentially some other HTML template library that might better suit their needs), should Handlebars really be a hard dependency for the package?

frinyvonnick commented 4 years ago

Hi @bentorkington 👋,

I made this package for my own purpose I often use handlebars to make images so it removes boilerplate for me. It could be an optional dependency. If the user provides the content option without installing handlebars it could throw an error. What do you think of it?

bentorkington commented 4 years ago

Hi @frinyvonnick 😀

Thanks for making your package available. This could work, another alternative might be to make two packages:

  1. one package with no Handlebars dependency which only performs image generation
  2. another package which is a wrapper for package 1 and uses Handlebars. Perhaps other templating engines like Nunjucks or Liquid would eventually get similar wrappers.

This would achieve the separation of concerns neatly while avoiding the error condition of not having Handlebars installed.

frinyvonnick commented 4 years ago

I can't make a separate package easily because of the multiple image generation. Can't figure out how to split this up while keeping this feature 🤔 Do you have an idea?

bentorkington commented 4 years ago

I'll get a PR in when I have time