Skip to content
Browse files

Fixed Issue #1212

  • Loading branch information...
1 parent 1bddaef commit 48c349c1dcc83a47341dc2d240d811190a7f80a7 @czpython committed Mar 19, 2013
View
2 cms/test_utils/project/templates/placeholder_tests/base.html
@@ -10,4 +10,4 @@
{% block three %}
{% placeholder "three" %}
-{% endblock %}
+{% endblock %}
View
2 cms/test_utils/project/templates/placeholder_tests/outside_nested.html
@@ -1 +1 @@
-{% extends "placeholder_tests/outside.html" %}
+{% extends "placeholder_tests/outside.html" %}
View
2 cms/test_utils/project/templates/placeholder_tests/test_one.html
@@ -13,4 +13,4 @@
{% block one %}
{% placeholder "new_one" %}
-{% endblock %}
+{% endblock %}
View
16 cms/tests/placeholder.py
@@ -46,6 +46,10 @@ def tearDown(self):
def test_placeholder_scanning_extend(self):
placeholders = get_placeholders('placeholder_tests/test_one.html')
self.assertEqual(sorted(placeholders), sorted([u'new_one', u'two', u'three']))
+
+ def test_placeholder_scanning_sekizai_extend(self):
+ placeholders = get_placeholders('placeholder_tests/test_one_sekizai.html')
+ self.assertEqual(sorted(placeholders), sorted([u'new_one', u'two', u'three']))
def test_placeholder_scanning_include(self):
placeholders = get_placeholders('placeholder_tests/test_two.html')
@@ -54,6 +58,10 @@ def test_placeholder_scanning_include(self):
def test_placeholder_scanning_double_extend(self):
placeholders = get_placeholders('placeholder_tests/test_three.html')
self.assertEqual(sorted(placeholders), sorted([u'new_one', u'two', u'new_three']))
+
+ def test_placeholder_scanning_sekizai_double_extend(self):
+ placeholders = get_placeholders('placeholder_tests/test_three_sekizai.html')
+ self.assertEqual(sorted(placeholders), sorted([u'new_one', u'two', u'new_three']))
def test_placeholder_scanning_complex(self):
placeholders = get_placeholders('placeholder_tests/test_four.html')
@@ -75,9 +83,17 @@ def test_placeholder_scanning_extend_outside_block(self):
placeholders = get_placeholders('placeholder_tests/outside.html')
self.assertEqual(sorted(placeholders), sorted([u'new_one', u'two', u'base_outside']))
+ def test_placeholder_scanning_sekizai_extend_outside_block(self):
+ placeholders = get_placeholders('placeholder_tests/outside_sekizai.html')
+ self.assertEqual(sorted(placeholders), sorted([u'new_one', u'two', u'base_outside']))
+
def test_placeholder_scanning_extend_outside_block_nested(self):
placeholders = get_placeholders('placeholder_tests/outside_nested.html')
self.assertEqual(sorted(placeholders), sorted([u'new_one', u'two', u'base_outside']))
+
+ def test_placeholder_scanning_sekizai_extend_outside_block_nested(self):
+ placeholders = get_placeholders('placeholder_tests/outside_nested_sekizai.html')
+ self.assertEqual(sorted(placeholders), sorted([u'new_one', u'two', u'base_outside']))
def test_fieldsets_requests(self):
response = self.client.get(reverse('admin:placeholderapp_example1_add'))
View
7 cms/utils/plugins.py
@@ -57,6 +57,7 @@ def _extend_nodelist(extend_node):
# we don't support variable extensions
if is_variable_extend_node(extend_node):
return []
+ # This is a dictionary mapping all BlockNode instances found in the template that contains extend_node
blocks = extend_node.blocks
_extend_blocks(extend_node, blocks)
placeholders = []
@@ -72,6 +73,8 @@ def _extend_nodelist(extend_node):
def _scan_placeholders(nodelist, current_block=None, ignore_blocks=None):
placeholders = []
if ignore_blocks is None:
+ # List of BlockNode instances to ignore.
+ # This is important to avoid processing overriden block nodes.
ignore_blocks = []
for node in nodelist:
@@ -105,15 +108,15 @@ def _scan_placeholders(nodelist, current_block=None, ignore_blocks=None):
if isinstance(subnodelist, NodeList):
if isinstance(node, BlockNode):
current_block = node
- placeholders += _scan_placeholders(subnodelist, current_block)
+ placeholders += _scan_placeholders(subnodelist, current_block, ignore_blocks)
# else just scan the node for nodelist instance attributes
else:
for attr in dir(node):
obj = getattr(node, attr)
if isinstance(obj, NodeList):
if isinstance(node, BlockNode):
current_block = node
- placeholders += _scan_placeholders(obj, current_block)
+ placeholders += _scan_placeholders(obj, current_block, ignore_blocks)
return placeholders
def get_placeholders(template):

0 comments on commit 48c349c

Please sign in to comment.
Something went wrong with that request. Please try again.