Kaydet (Commit) 63cf85b6 authored tarafından Adrian Holovaty's avatar Adrian Holovaty

Moved custom unit-test templatetag library into the unit test module itself, to…

Moved custom unit-test templatetag library into the unit test module itself, to fix errors when running the test module directly.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@1586 bcc190cf-cafb-0310-a4f2-bffc1f526a37
üst 4e700685
......@@ -8,7 +8,30 @@ from django.core.template import loader
from django.utils.translation import activate, deactivate, install
import traceback
# Helper objects for template tests
#################################
# Custom template tag for tests #
#################################
register = template.Library()
class EchoNode(template.Node):
def __init__(self, contents):
self.contents = contents
def render(self, context):
return " ".join(self.contents)
def do_echo(parser, token):
return EchoNode(token.contents.split()[1:])
register.tag("echo", do_echo)
template.libraries['django.templatetags.testtags'] = register
#####################################
# Helper objects for template tests #
#####################################
class SomeClass:
def __init__(self):
self.otherclass = OtherClass()
......
# Custom tag library used in conjunction with template tests
from django.core import template
register = template.Library()
class EchoNode(template.Node):
def __init__(self, contents):
self.contents = contents
def render(self, context):
return " ".join(self.contents)
def do_echo(parser, token):
return EchoNode(token.contents.split()[1:])
register.tag("echo", do_echo)
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment