Webpack loader for Nunjucks templates
MIT License
Bot releases are visible (Hide)
Published by ogonkov almost 4 years ago
Published by ogonkov over 4 years ago
BREAKING CHANGE: global function static
replaced with static
tag (#74). This happens because globals is not supporting async operations, while dynamic assets is using promises, when loaded with import()
syntax. To upgrade to this version you need to replace all global static
invocation with new static
tag.
- {{ static('image.png') }}
+ {% static 'image.png' %}
- {% set foo = static('bar.jpg') %}
+ {% static 'bar.jpg' as foo %}
BREAKING CHANGE: handling of async templates is now even better (#67). When loader found async tags or extensions it calls template render via callback, and wrap it to Promise
. It was only available for asynchronous filters before, and in some cases could prevent templates from proper rendering, now it should cover all cases, when asynchronous render required.
New option esModule
added (#65). It will change output to ES module syntax.
Minor changes to readme (#63), defaults handling (#72), refactoring (#73)
Published by ogonkov almost 5 years ago
First major version!
Assets could be loaded with expressions:
{% set user_id = '100500' %}
<img alt="" src="{{ static('avatars/' + user_id + '.png') }}" />
Package now contains optional glob
dependency. It's required for for dynamic assets described above. If you don't use loading of assets with expression, then you could add --no-optional
flag when install package.
Assets support added (#28)
Now you can use builtin static()
function, that will resolve given string through webpack loaders
<img src="{{ static('app_example_a/image.png') }}" />
See README for more examples.
GitHub page added (not useful for that moment).
Published by ogonkov almost 5 years ago
API is now should be stable enough, so next version should be beta with assets loading support.
(finally) filters support added 🎊 (#25)
Imported template function returns a string by default:
/**
* @type {function(Object): string}
*/
import template from 'template.njk';
with asynchronous filters it now returns Promise
(i haven't test it for compatibility with html-webpack-loader
):
/**
* @type {function(Object):Promise.<string, Error>}
*/
import asyncTemplate from 'async-template.njk';
Custom extensions imports was not checked for duplicates (#26)
Loader now compatible with exports-loader
(#21)
Published by ogonkov almost 5 years ago
Published by ogonkov about 5 years ago
nunjucks.installJinjaCompat
invocation from optionsPublished by ogonkov about 5 years ago
Published by ogonkov about 5 years ago
nunjucks.parser
to find all dependencies