Refs #24451 -- Removed comma-separated {% cycle %} syntax per deprecation timeline.

This commit is contained in:
Tim Graham 2015-08-17 09:47:55 -04:00
parent 04ee4059d7
commit 27b2321793
3 changed files with 1 additions and 54 deletions

View File

@ -619,15 +619,6 @@ def cycle(parser, token):
if len(args) < 2: if len(args) < 2:
raise TemplateSyntaxError("'cycle' tag requires at least two arguments") raise TemplateSyntaxError("'cycle' tag requires at least two arguments")
if ',' in args[1]:
warnings.warn(
"The old {% cycle %} syntax with comma-separated arguments is deprecated.",
RemovedInDjango110Warning,
)
# Backwards compatibility: {% cycle a,b %} or {% cycle a,b as foo %}
# case.
args[1:2] = ['"%s"' % arg for arg in args[1].split(",")]
if len(args) == 2: if len(args) == 2:
# {% cycle foo %} case. # {% cycle foo %} case.
name = args[1] name = args[1]

View File

@ -185,18 +185,6 @@ call to ``{% cycle %}`` doesn't specify ``silent``::
{% cycle 'row1' 'row2' as rowcolors silent %} {% cycle 'row1' 'row2' as rowcolors silent %}
{% cycle rowcolors %} {% cycle rowcolors %}
.. deprecated:: 1.9
The ``{% cycle %}`` tag supports the much inferior old syntax from previous
Django versions. You shouldn't use this in any new projects, but for the
sake of the people who are still using it, here's what it looks like::
{% cycle row1,row2,row3 %}
In this syntax, each value gets interpreted as a literal string, and there's
no way to specify variable values, literal commas, or spaces. Support for
this syntax will be removed in Django 1.10.
.. templatetag:: debug .. templatetag:: debug
debug debug

View File

@ -1,6 +1,5 @@
from django.template import TemplateSyntaxError from django.template import TemplateSyntaxError
from django.test import SimpleTestCase, ignore_warnings from django.test import SimpleTestCase
from django.utils.deprecation import RemovedInDjango110Warning
from ..utils import setup from ..utils import setup
@ -12,24 +11,6 @@ class CycleTagTests(SimpleTestCase):
with self.assertRaises(TemplateSyntaxError): with self.assertRaises(TemplateSyntaxError):
self.engine.get_template('cycle01') self.engine.get_template('cycle01')
@ignore_warnings(category=RemovedInDjango110Warning)
@setup({'cycle02': '{% cycle a,b,c as abc %}{% cycle abc %}'})
def test_cycle02(self):
output = self.engine.render_to_string('cycle02')
self.assertEqual(output, 'ab')
@ignore_warnings(category=RemovedInDjango110Warning)
@setup({'cycle03': '{% cycle a,b,c as abc %}{% cycle abc %}{% cycle abc %}'})
def test_cycle03(self):
output = self.engine.render_to_string('cycle03')
self.assertEqual(output, 'abc')
@ignore_warnings(category=RemovedInDjango110Warning)
@setup({'cycle04': '{% cycle a,b,c as abc %}{% cycle abc %}{% cycle abc %}{% cycle abc %}'})
def test_cycle04(self):
output = self.engine.render_to_string('cycle04')
self.assertEqual(output, 'abca')
@setup({'cycle05': '{% cycle %}'}) @setup({'cycle05': '{% cycle %}'})
def test_cycle05(self): def test_cycle05(self):
with self.assertRaises(TemplateSyntaxError): with self.assertRaises(TemplateSyntaxError):
@ -40,24 +21,11 @@ class CycleTagTests(SimpleTestCase):
with self.assertRaises(TemplateSyntaxError): with self.assertRaises(TemplateSyntaxError):
self.engine.get_template('cycle06') self.engine.get_template('cycle06')
@ignore_warnings(category=RemovedInDjango110Warning)
@setup({'cycle07': '{% cycle a,b,c as foo %}{% cycle bar %}'}) @setup({'cycle07': '{% cycle a,b,c as foo %}{% cycle bar %}'})
def test_cycle07(self): def test_cycle07(self):
with self.assertRaises(TemplateSyntaxError): with self.assertRaises(TemplateSyntaxError):
self.engine.get_template('cycle07') self.engine.get_template('cycle07')
@ignore_warnings(category=RemovedInDjango110Warning)
@setup({'cycle08': '{% cycle a,b,c as foo %}{% cycle foo %}{{ foo }}{{ foo }}{% cycle foo %}{{ foo }}'})
def test_cycle08(self):
output = self.engine.render_to_string('cycle08')
self.assertEqual(output, 'abbbcc')
@ignore_warnings(category=RemovedInDjango110Warning)
@setup({'cycle09': '{% for i in test %}{% cycle a,b %}{{ i }},{% endfor %}'})
def test_cycle09(self):
output = self.engine.render_to_string('cycle09', {'test': list(range(5))})
self.assertEqual(output, 'a0,b1,a2,b3,a4,')
@setup({'cycle10': "{% cycle 'a' 'b' 'c' as abc %}{% cycle abc %}"}) @setup({'cycle10': "{% cycle 'a' 'b' 'c' as abc %}{% cycle abc %}"})
def test_cycle10(self): def test_cycle10(self):
output = self.engine.render_to_string('cycle10') output = self.engine.render_to_string('cycle10')