Skip to content

Commit fb936bd

Browse files
committed
Add Jinja section
1 parent c5427b6 commit fb936bd

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

README.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -390,6 +390,32 @@ On your template, render the bundle as usual:
390390
### Hot reload
391391
In case you wish to enable hot reload for your project using `django-webpack-loader` and `webpack-bundle-tracker`, please check out [this example](https://github.com/django-webpack/django-webpack-loader/tree/master/examples/hot-reload), in particular how [server.js](https://github.com/django-webpack/django-webpack-loader/blob/master/examples/hot-reload/server.js) and [webpack.config.js](https://github.com/django-webpack/django-webpack-loader/blob/master/examples/hot-reload/webpack.config.js) are configured.
392392

393+
### Jinja2 Configuration
394+
395+
If you need to output your assets in a jinja template, we provide a Jinja2 extension that's compatible with the [Django Jinja](https://github.com/niwinz/django-jinja) module and Django 1.8.
396+
397+
To install the extension add it to the django_jinja `TEMPLATES` configuration in the `["OPTIONS"]["extension"]` list.
398+
399+
```python
400+
from django_jinja.builtins import DEFAULT_EXTENSIONS
401+
TEMPLATES = [
402+
{
403+
"BACKEND": "django_jinja.backend.Jinja2",
404+
"OPTIONS": {
405+
"extensions": DEFAULT_EXTENSIONS + [
406+
"webpack_loader.contrib.jinja2ext.WebpackExtension",
407+
],
408+
}
409+
}
410+
]
411+
```
412+
413+
Then in your base jinja template:
414+
415+
```HTML
416+
{{ render_bundle('main') }}
417+
```
418+
393419
## Migrating from version < 1.0.0
394420

395421
In order to use `django-webpack-loader>=1.0.0`, you must ensure that `[email protected]` is being used on the JavaScript side. It's recommended that you always keep at least minor version parity across both packages, for full compatibility.

0 commit comments

Comments
 (0)