diff --git a/CHANGES b/CHANGES index b99ff1dd8d8cf8d5829d48959ff5cf23b5cebd78..6dfc012d39eb79c293b3ca6e7be9bbc1c6ce9f62 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 c0f78adc95f807d787dd5537c793b8b6a8d609fc..c9913ebf62af0eef5d888a39585ecdc3c8418bc6 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 6b7c1d35e86bbaec802c90f02a3390721220e76c..e75b7d0bf5431725d317ee67bd07ad3ae04f2b32 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 df47d10c8b0246f53b1510e47c157bfd4cd2e2fb..0243bb1e61aaee106a1e8d5fb61d5ee1e17e193b 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 f6bbf01207143938f8446f088ae6ffbcd4730c80..8769da03db9011cb09eb04c926aef0f2b46ab480 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)