Fixed #5478 -- Fixed bug in lorem template tag. Thanks, racter

git-svn-id: http://code.djangoproject.com/svn/django/trunk@6228 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Adrian Holovaty 2007-09-14 22:03:47 +00:00
parent 4f70820dc1
commit 59964c2c3f
2 changed files with 5 additions and 1 deletions

View File

@ -62,6 +62,6 @@ def lorem(parser, token):
count = '1' count = '1'
count = parser.compile_filter(count) count = parser.compile_filter(count)
if len(bits) != 1: if len(bits) != 1:
raise TemplateSyntaxError("Incorrect format for %r tag" % tagname) raise template.TemplateSyntaxError("Incorrect format for %r tag" % tagname)
return LoremNode(count, method, common) return LoremNode(count, method, common)
lorem = register.tag(lorem) lorem = register.tag(lorem)

View File

@ -7,6 +7,10 @@ u'lorem ipsum dolor sit amet consectetur adipisicing'
>>> paragraphs(1) >>> paragraphs(1)
['Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.'] ['Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.']
>>> from django.template import loader, Context
>>> t = loader.get_template_from_string("{% load webdesign %}{% lorem 3 w %}")
>>> t.render(Context({}))
u'lorem ipsum dolor'
""" """
from django.contrib.webdesign.lorem_ipsum import * from django.contrib.webdesign.lorem_ipsum import *