From ac70fbfb7f8349e5c1150f40bf1d21ba635d0cb8 Mon Sep 17 00:00:00 2001
From: Chirag Jadwani <cbjadwani@elance-odesk.com>
Date: Fri, 29 Aug 2014 13:15:35 +0530
Subject: [PATCH] Fix AttributeError in offline compression
---
compressor/offline/django.py | 2 ++
.../test_block_super_base_compressed/test_compressor_offline.html | 5 +++++
2 files changed, 7 insertions(+)
diff --git a/compressor/offline/django.py b/compressor/offline/django.py
index 3986562..b326093 100644
--- a/compressor/offline/django.py
+++ b/compressor/offline/django.py
@@ -54,6 +54,8 @@ def remove_block_nodes(nodelist, block_stack, block_context):
if not block_stack:
continue
node = block_context.get_block(block_stack[-1].name)
+ if not node:
+ continue
if isinstance(node, BlockNode):
expanded_block = expand_blocknode(node, block_stack, block_context)
new_nodelist.extend(expanded_block)
diff --git a/compressor/tests/test_templates/test_block_super_base_compressed/test_compressor_offline.html b/compressor/tests/test_templates/test_block_super_base_compressed/test_compressor_offline.html
index 01382ec..10097c1 100644
--- a/compressor/tests/test_templates/test_block_super_base_compressed/test_compressor_offline.html
+++ b/compressor/tests/test_templates/test_block_super_base_compressed/test_compressor_offline.html
@@ -5,4 +5,9 @@
<script type="text/javascript">
alert("this alert shouldn't be alone!");
</script>
+ {% block orphan %}
+ {{ block.super }}
+ An 'orphan' block that refers to a non-existent super block.
+ Contents of this block are ignored.
+ {% endblock %}
{% endspaceless %}{% endblock %}