summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2011-07-08 10:09:03 -0400
committerMike Bayer <mike_mp@zzzcomputing.com>2011-07-08 10:09:03 -0400
commit4f554cb3f613ed8910ea3524a0787b3b726ea6ae (patch)
tree65f5ebcfeb18dcd7a8535576d5125910ca14fb43
parent926cbf2c0296f77c9b0e06fdf6a82a946101aa49 (diff)
downloadmako-4f554cb3f613ed8910ea3524a0787b3b726ea6ae.tar.gz
- Fixed the babel plugin to accommodate <%block>
[ticket:169]
-rw-r--r--CHANGES4
-rw-r--r--mako/__init__.py2
-rw-r--r--mako/ext/babelplugin.py3
-rw-r--r--test/templates/gettext.mako6
-rw-r--r--test/test_babelplugin.py14
5 files changed, 22 insertions, 7 deletions
diff --git a/CHANGES b/CHANGES
index b99ff1d..6dfc012 100644
--- a/CHANGES
+++ b/CHANGES
@@ -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.
diff --git a/mako/__init__.py b/mako/__init__.py
index c0f78ad..c9913eb 100644
--- a/mako/__init__.py
+++ b/mako/__init__.py
@@ -5,5 +5,5 @@
# the MIT License: http://www.opensource.org/licenses/mit-license.php
-__version__ = '0.4.1'
+__version__ = '0.4.2'
diff --git a/mako/ext/babelplugin.py b/mako/ext/babelplugin.py
index 6b7c1d3..e75b7d0 100644
--- a/mako/ext/babelplugin.py
+++ b/mako/ext/babelplugin.py
@@ -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
diff --git a/test/templates/gettext.mako b/test/templates/gettext.mako
index df47d10..0243bb1 100644
--- a/test/templates/gettext.mako
+++ b/test/templates/gettext.mako
@@ -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
diff --git a/test/test_babelplugin.py b/test/test_babelplugin.py
index f6bbf01..8769da0 100644
--- a/test/test_babelplugin.py
+++ b/test/test_babelplugin.py
@@ -31,12 +31,14 @@ class ExtractMakoTestCase(TemplateTest):
(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)