0001-misc-add-startswith-templatetag-25972.patch
tests/test_templates.py | ||
---|---|---|
67 | 67 |
tmpl = Template('{% load i18n %}{% trans "hello" %}') |
68 | 68 |
assert tmpl.render() == 'hello' |
69 | 69 | |
70 |
def test_startswith_templatetag(): |
|
71 |
tmpl = Template('{% if foo|startswith:"bar" %}hello{% endif %}') |
|
72 |
assert tmpl.render() == '' |
|
73 |
assert tmpl.render({'foo': 'bar-baz'}) == 'hello' |
|
74 |
assert tmpl.render({'foo': 'baz-bar'}) == '' |
|
75 | ||
70 | 76 |
def test_template_encoding(): |
71 | 77 |
# django |
72 | 78 |
tmpl = Template('{{ foo }} à vélo') |
wcs/qommon/templatetags/qommon.py | ||
---|---|---|
27 | 27 |
def get(mapping, key): |
28 | 28 |
return mapping.get(key) |
29 | 29 | |
30 |
@register.filter |
|
31 |
def startswith(string, substring): |
|
32 |
return string and string.startswith(substring) |
|
33 | ||
30 | 34 |
@register.filter |
31 | 35 |
def parse_date(date_string): |
32 | 36 |
try: |
33 |
- |