Skip to content
This repository has been archived by the owner on Aug 17, 2023. It is now read-only.

Commit

Permalink
Add support for a plural tag within a blocktrans tag
Browse files Browse the repository at this point in the history
  • Loading branch information
rowanseymour committed Feb 7, 2017
1 parent 3a951d2 commit 5bf376f
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
1 change: 1 addition & 0 deletions hamlpy/compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ class Compiler:
'compress': 'endcompress'
},
'may_contain': {
'blocktrans': ['plural'],
'if': ['else', 'elif'],
'ifchanged': ['else'],
'ifequal': ['else'],
Expand Down
16 changes: 16 additions & 0 deletions hamlpy/test/test_compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,22 @@ def test_django_tags(self):
self._test('- with context\n hello\n- with other_context\n goodbye',
'{% with context %}\n hello\n{% endwith %}\n{% with other_context %}\n goodbye\n{% endwith %}')

# blocktrans
self._test('- blocktrans with amount=num_cookies\n'
' There are #{ amount } cookies',
'{% blocktrans with amount=num_cookies %}\n'
' There are {{ amount }} cookies\n'
'{% endblocktrans %}')
self._test('- blocktrans with amount=num_cookies\n'
' There is one cookie\n'
'- plural\n'
' There are #{ amount } cookies',
'{% blocktrans with amount=num_cookies %}\n'
' There is one cookie\n'
'{% plural %}\n'
' There are {{ amount }} cookies\n'
'{% endblocktrans %}')

# exception using a closing tag of a self-closing tag
parser = Compiler()
self.assertRaises(ParseException, parser.process, '- endfor')
Expand Down

0 comments on commit 5bf376f

Please sign in to comment.