SudoCat / Nunjucks-Isomorphic-Loader

Nunjucks loader for webpack, supporting both javascript templating and generating static HTML files through the HtmlWebpackPlugin.
MIT License
16 stars 5 forks source link

Update README.md #2

Closed 3dos closed 6 years ago

3dos commented 6 years ago

Adding usage inspired from https://gist.github.com/SudoCat/7c1323eeff1e83ed2a69b004b8c6024b

SudoCat commented 6 years ago

Woohoo! Thanks for being the first to contribute, hopefully this extension has been useful to you.

I'm happy to go ahead and merge this, however I thought that other extensions should be possible (albeit a limited selection) through the test option. Admittedly, I primarily only use .njk files, so I can't remember for certain.

This section of the code looks like I did try to consider other templates:

https://github.com/SudoCat/Nunjucks-Isomorphic-Loader/blob/master/src/node-loader.js#L54

Did your experience suggest otherwise?

3dos commented 6 years ago

Thank to you I finally managed to use nunjucks templates with the html-webpack-plugin (no luck with the other loaders out there that could not provide data from webpack to the templates)

I didn't test other extensions than .njk but read it was the only supported ones. I could be wrong on this one.

I just felt frustrated not to have a simple usage docs on the readme so I added it for future users \o/

PS: This is my first PR ever haha

SudoCat commented 6 years ago

That's excellent! I'm glad to hear it, I encountered the exact same issue, so I wrote this to try and solve that. Stoked to hear it's been useful for someone else 😄

Well, I'll leave it in there then, as .njk is the only one that we know for certain is working! Hopefully I'll get an opportunity to test that and update it.

Thanks a bunch for taking the time to do this - I really should have done it sooner, but honestly still a little surprised to see other people finding this!

Haha, congratulations! This is the first PR I've ever received on any OSS, so it's an exciting time for the both of us! 🎆 🎉

3dos commented 6 years ago

WooHoo :p Here's a little history that lead me here https://stackoverflow.com/questions/47335302/using-nunjucks-with-htmlwebpackplugin-using-dynamic-vars-in-the-template

Glad it's as exiting for you as it is for me