Commits

Mike Bayer  committed 4f554cb

- Fixed the babel plugin to accommodate <%block>
[ticket:169]

  • Participants
  • Parent commits 926cbf2

Comments (0)

Files changed (5)

+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.  

File mako/__init__.py

 # the MIT License: http://www.opensource.org/licenses/mit-license.php
 
 
-__version__ = '0.4.1'
+__version__ = '0.4.2'
 

File mako/ext/babelplugin.py

         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

File test/templates/gettext.mako

   <!-- ${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

File test/test_babelplugin.py

              (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)