Skip to content

Commit e9cff68

Browse files
rvlbfjsj
authored andcommitted
Fix get_files on readme
1 parent a234f7f commit e9cff68

File tree

2 files changed

+15
-5
lines changed

2 files changed

+15
-5
lines changed

README.md

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -305,16 +305,26 @@ WEBPACK_LOADER = {
305305

306306
If you need the URL to an asset without the HTML tags, the `get_files` template tag can be used. A common use case is specifying the URL to a custom css file for a Javascript plugin.
307307

308-
`get_files` works exactly like `render_bundle` except it returns a list of matching files and lets you assign the list to a custom template variable. For example:
308+
`get_files` works exactly like `render_bundle` except it returns a list of matching files and lets you assign the list to a custom template variable.
309+
310+
Each object in the returned list has 2 properties:
311+
1. `name`, which is the name of the chunk from the stats file;
312+
2. `url`, which can be:
313+
1. The `publicPath` if the asset has one;
314+
2. The `path` to the asset in the static files storage, if the asset doesn't have a `publicPath`.
315+
316+
For example:
309317

310318
```HTML+Django
319+
{% load get_files from webpack_loader %}
320+
311321
{% get_files 'editor' 'css' as editor_css_files %}
312-
CKEDITOR.config.contentsCss = '{{ editor_css_files.0.publicPath }}';
322+
CKEDITOR.config.contentsCss = '{{ editor_css_files.0.url }}';
313323
314-
<!-- or list down name, path and download url for every file -->
324+
<!-- or list down name and url for every file -->
315325
<ul>
316326
{% for css_file in editor_css_files %}
317-
<li>{{ css_file.name }} : {{ css_file.path }} : {{ css_file.publicPath }}</li>
327+
<li>{{ css_file.name }} : {{ css_file.url }}</li>
318328
{% endfor %}
319329
</ul>
320330
```

webpack_loader/templatetags/webpack_loader.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ def get_files(bundle_name, extension=None, config='DEFAULT'):
4646
Example usage::
4747
4848
{% get_files 'editor' 'css' as editor_css_chunks %}
49-
CKEDITOR.config.contentsCss = '{{ editor_css_chunks.0.publicPath }}';
49+
CKEDITOR.config.contentsCss = '{{ editor_css_chunks.0.url }}';
5050
5151
:param bundle_name: The name of the bundle
5252
:param extension: (optional) filter by extension

0 commit comments

Comments
 (0)