-
-
Notifications
You must be signed in to change notification settings - Fork 125
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[feature]: html
as an array
#190
Comments
Hi @hefler 👋 Thx for opening this issue. Could you provide some concrete examples of usage so I could better understand your idea please? |
I'll use the example from the README#Genrating Multiple Images as a base. const liquidjsHTML = liquidjsRenderFunction( 'template.liquid', objectWithSomeData ); //outputs an HTML
const pugHTML = pugsRenderFunction( 'template.pug'', objectWithSomeData ); //outputs an HTML
const preRenderedHTMLs = [ liquidjsHTML, pugHTML ];
nodeHtmlToImage({
html: preRenderedHTMLs,
content: [{ output: './image1.png' }, { output: './image2.png' }]
})
.then(() => console.log('The images were created successfully!')) Does that makes sense? Also might be worth to mention that in my case the same template has the logic to generate multiple different images. The only reason I'm not using ✌️ |
@hefler I am somewhat divided over this issue. Your solution make node-html-to-image compatible with every template engine. On the other hand for my own usage I like that node-html-to-image supports directly handlebars. If we keep both there are two ways of using the library 🤔 I feels like there is a choice to make. Another solution would be to add support for liquidjs in node-html-to-image and introduce an option What do you think? |
@frinyvonnick Re-reading the issue made me question the quality of my writing. 😅
Regarding item 1, I think it'd be nice to have multiple input sources (multiple HTMLs). It'd be needed to rethink a bit how the library would deal with the pairs const html1 = '<html><body>I’m {{ name }}</body></html>';
const html2 = '<html><body>My name is: {{ name }}</body></html>';
const htmls = [ html1, html2 ];
nodeHtmlToImage({
html: htmls,
content: [{ output: './image1.png' }, { output: './image2.png' }]
})
.then(() => console.log('Images created'))
// OUTPUTS:
// image1_html1.png
// image2_html2.png
// OR
// image1_html1.png
// image1_html2.png
// image2_html1.png
// image2_html2.png As for item 2, Introducing Apologies if things got a bit convoluted. |
First of all, thanks for this great library!
I'm using this lib to generate multiple images in a project that happens to use
liquidjs
instead ofhandlebarsjs
. Since issue #47 is ongoing, I'd like to suggest that thehtml
property to also accept arrays, like it already does forcontent
. In this case one could render the HTML using a rendering engine of his/hers liking yet generating multiple images.On a personal note I'd love to have an
htmlRender
property which could deal with any specific template render engine. It also could be a way for gracefully deprecate anyhandlerbarsjs
options without introducing breaking changes.The text was updated successfully, but these errors were encountered: