Skip to content

Commit de2bebb

Browse files
committed
Improves formatting for legibility
1 parent 3f226d0 commit de2bebb

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

tests/app/tests/test_webpack.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -334,8 +334,9 @@ def test_request_blocking(self):
334334
self.assertTrue(elapsed < wait_for)
335335

336336
def test_skip_common_chunks_djangoengine(self):
337-
'Test case for deduplication of modules with the django engine.'
337+
"""Test case for deduplication of modules with the django engine."""
338338
self.compile_bundles('webpack.config.skipCommon.js')
339+
339340
django_engine = engines['django']
340341
dups_template = django_engine.from_string(template_code=(
341342
r'{% load render_bundle from webpack_loader %}'
@@ -354,11 +355,13 @@ def test_skip_common_chunks_djangoengine(self):
354355
rendered_template = dups_template.render(
355356
context=None, request=request)
356357
used_tags = getattr(request, '_webpack_loader_used_tags', None)
358+
357359
self.assertIsNotNone(used_tags, msg=(
358360
'_webpack_loader_used_tags should be a property of request!'))
359361
self.assertEqual(rendered_template.count(asset_app1), 1)
360362
self.assertEqual(rendered_template.count(asset_app2), 1)
361363
self.assertEqual(rendered_template.count(asset_vendor), 2)
364+
362365
nodups_template = django_engine.from_string(template_code=(
363366
r'{% load render_bundle from webpack_loader %}'
364367
r'{% render_bundle "app1" %}'
@@ -368,15 +371,17 @@ def test_skip_common_chunks_djangoengine(self):
368371
rendered_template = nodups_template.render(
369372
context=None, request=request)
370373
used_tags = getattr(request, '_webpack_loader_used_tags', None)
374+
371375
self.assertIsNotNone(used_tags, msg=(
372376
'_webpack_loader_used_tags should be a property of request!'))
373377
self.assertEqual(rendered_template.count(asset_app1), 1)
374378
self.assertEqual(rendered_template.count(asset_app2), 1)
375379
self.assertEqual(rendered_template.count(asset_vendor), 1)
376380

377381
def test_skip_common_chunks_jinja2engine(self):
378-
'Test case for deduplication of modules with the Jinja2 engine.'
382+
"""Test case for deduplication of modules with the Jinja2 engine."""
379383
self.compile_bundles('webpack.config.skipCommon.js')
384+
380385
view = TemplateView.as_view(template_name='home-deduplicated.jinja')
381386
settings = {
382387
'TEMPLATES': [
@@ -399,6 +404,7 @@ def test_skip_common_chunks_jinja2engine(self):
399404
asset_app2 = (
400405
'<script src="/static/django_webpack_loader_bundles/app2.js" >'
401406
'</script>')
407+
402408
with self.settings(**settings):
403409
request = self.factory.get('/')
404410
result = view(request) # type: TemplateResponse

webpack_loader/templatetags/webpack_loader.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,15 @@ def render_bundle(
3535
tags = utils.get_as_tags(
3636
bundle_name, extension=extension, config=config, suffix=suffix,
3737
attrs=attrs, is_preload=is_preload)
38+
3839
if not hasattr(context['request'], '_webpack_loader_used_tags'):
3940
context['request']._webpack_loader_used_tags = set()
41+
4042
used_tags = context['request']._webpack_loader_used_tags
4143
if skip_common_chunks:
4244
tags = [tag for tag in tags if tag not in used_tags]
4345
used_tags.update(tags)
46+
4447
return mark_safe('\n'.join(tags))
4548

4649

0 commit comments

Comments
 (0)