| 11 | | # Helper objects for template tests |
|---|
| | 11 | ################################# |
|---|
| | 12 | # Custom template tag for tests # |
|---|
| | 13 | ################################# |
|---|
| | 14 | |
|---|
| | 15 | register = template.Library() |
|---|
| | 16 | |
|---|
| | 17 | class EchoNode(template.Node): |
|---|
| | 18 | def __init__(self, contents): |
|---|
| | 19 | self.contents = contents |
|---|
| | 20 | |
|---|
| | 21 | def render(self, context): |
|---|
| | 22 | return " ".join(self.contents) |
|---|
| | 23 | |
|---|
| | 24 | def do_echo(parser, token): |
|---|
| | 25 | return EchoNode(token.contents.split()[1:]) |
|---|
| | 26 | |
|---|
| | 27 | register.tag("echo", do_echo) |
|---|
| | 28 | |
|---|
| | 29 | template.libraries['django.templatetags.testtags'] = register |
|---|
| | 30 | |
|---|
| | 31 | ##################################### |
|---|
| | 32 | # Helper objects for template tests # |
|---|
| | 33 | ##################################### |
|---|
| | 34 | |
|---|