Skip to content

Commit

Permalink
- Fixed the babel plugin to accommodate <%block>
Browse files Browse the repository at this point in the history
  [ticket:169]
  • Loading branch information
zzzeek committed Jul 8, 2011
1 parent 926cbf2 commit 4f554cb
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 7 deletions.
4 changes: 4 additions & 0 deletions CHANGES
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
0.4.2
- Fixed the babel plugin to accommodate <%block>
[ticket:169]

0.4.1
- New tag: <%block>. A variant on <%def> that
evaluates its contents in-place.
Expand Down
2 changes: 1 addition & 1 deletion mako/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@
# the MIT License: http://www.opensource.org/licenses/mit-license.php


__version__ = '0.4.1'
__version__ = '0.4.2'

3 changes: 3 additions & 0 deletions mako/ext/babelplugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,9 @@ def extract_nodes(nodes, keywords, comment_tags, options):
if isinstance(node, parsetree.DefTag):
code = node.function_decl.code
child_nodes = node.nodes
elif isinstance(node, parsetree.BlockTag):
code = node.body_decl.code
child_nodes = node.nodes
elif isinstance(node, parsetree.CallTag):
code = node.code.code
child_nodes = node.nodes
Expand Down
6 changes: 6 additions & 0 deletions test/templates/gettext.mako
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,12 @@ top = gettext('Begin')
<!-- ${caller.body()} -->
</%def>

<%block name="foo">
## TRANSLATOR: Ensure so and
## so, thanks
${_('The')} fuzzy ${ungettext('bunny', 'bunnies', random.randint(1, 2))}
</%block>

<%call expr="comment">
P.S.
## TRANSLATOR: HTML comment
Expand Down
14 changes: 8 additions & 6 deletions test/test_babelplugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,14 @@ def test_extract(self):
(41, '_', u'Goodbye', [u'TRANSLATOR: Good bye']),
(44, '_', u'Babel', []),
(45, 'ungettext', (u'hella', u'hellas', None), []),
(62, '_', u'Goodbye, really!', [u'TRANSLATOR: HTML comment']),
(65, '_', u'P.S. byebye', []),
(71, '_', u'Top', []),
(77, '_', u'foo', []),
(77, '_', u'baz', []),
(79, '_', u'bar', [])
(62, '_', u'The', [u'TRANSLATOR: Ensure so and', u'so, thanks']),
(62, 'ungettext', (u'bunny', u'bunnies', None), []),
(68, '_', u'Goodbye, really!', [u'TRANSLATOR: HTML comment']),
(71, '_', u'P.S. byebye', []),
(77, '_', u'Top', []),
(83, '_', u'foo', []),
(83, '_', u'baz', []),
(85, '_', u'bar', [])
]
self.assertEqual(expected, messages)

0 comments on commit 4f554cb

Please sign in to comment.