diff --git a/tests/regressiontests/templates/object_tag.py b/tests/regressiontests/templates/object_tag.py
new file mode 100644
index 0000000..5f67b9e
-
|
+
|
|
| 1 | object_tag_tests = """ |
| 2 | >>> t = template.Template('{% load custom %}{% get_meaning_of_life as answer %}{{ answer }}') |
| 3 | >>> t.render(template.Context()) |
| 4 | u"42" |
| 5 | >>> t = template.Template('{% load custom %}{% get_mascot_with "awesomeness" "magical powers" as pony %}{{ pony }}') |
| 6 | >>> t.render(template.Context()) |
| 7 | u"This mascot is filled with awesomeness and magical powers" |
| 8 | >>> t = template.Template('{% load custom %}{% count "e" word as num %}{{ num }}') |
| 9 | >>> t.render(template.Context({'word': 'beefcake'})) |
| 10 | u"3" |
| 11 | """ |
diff --git a/tests/regressiontests/templates/templatetags/custom.py b/tests/regressiontests/templates/templatetags/custom.py
index fdf8d10..bbb8c08 100644
a
|
b
|
trim = stringfilter(trim)
|
9 | 9 | |
10 | 10 | register.filter(trim) |
11 | 11 | |
| 12 | def get_meaning_of_life(): |
| 13 | return 42 |
| 14 | register.object_tag(get_meaning_of_life) |
| 15 | |
| 16 | def get_mascot_with(power_one, power_two): |
| 17 | return 'This mascot is filled with %s and %s' % (power_one, power_two) |
| 18 | register.object_tag(get_mascot_with) |
| 19 | |
| 20 | def count(char, word): |
| 21 | return word.count(char) |
| 22 | register.object_tag(count) |
diff --git a/tests/regressiontests/templates/tests.py b/tests/regressiontests/templates/tests.py
index 9c01b49..0badc86 100644
a
|
b
|
from context import context_tests
|
24 | 24 | from custom import custom_filters |
25 | 25 | from parser import filter_parsing, variable_parsing |
26 | 26 | from unicode import unicode_tests |
| 27 | from object_tag import object_tag_tests |
27 | 28 | |
28 | 29 | try: |
29 | 30 | from loaders import * |
… |
… |
__test__ = {
|
38 | 39 | 'context': context_tests, |
39 | 40 | 'filter_parsing': filter_parsing, |
40 | 41 | 'custom_filters': custom_filters, |
| 42 | 'object_tag': object_tag_tests, |
41 | 43 | } |
42 | 44 | |
43 | 45 | ################################# |