Skip to content

Commit

Permalink
Merge pull request mikeboers#10 from epegzz/master
Browse files Browse the repository at this point in the history
pull request: unicode support in haml function arguments
  • Loading branch information
mikeboers committed May 18, 2011
2 parents aa4c3bd + ade6ab7 commit 07532b3
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 2 deletions.
2 changes: 1 addition & 1 deletion haml/codegen.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ def adapt_camelcase(name, seperator):
def _format_mako_attr_pair(k, v):
if v is True:
v = k
return ' %s="%s"' % (k, cgi.escape(str(v)))
return ' %s="%s"' % (k, cgi.escape("%s" % v))



Expand Down
14 changes: 14 additions & 0 deletions haml/util.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@


def extract_haml(fileobj, keywords, comment_tags, options):
""" babel translation token extract function for haml files """

import haml
from mako import lexer, parsetree
from mako.ext.babelplugin import extract_nodes

encoding = options.get('input_encoding', options.get('encoding', None))
template_node = lexer.Lexer(haml.preprocessor(fileobj.read()), input_encoding=encoding).parse()
for extracted in extract_nodes(template_node.get_children(), keywords, comment_tags, options):
yield extracted

10 changes: 9 additions & 1 deletion tests/test_pythonisms.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# -*- coding: utf-8 -*-
from . import Base

class TestAttributes(Base):


def test_raw_attribute_names(self):
self.assertHTML(
Expand All @@ -19,4 +21,10 @@ def test_camelcase_override(self):
'%({"positionalDict":"xxx"}, keywordArgument="xxx", __adapt_camelcase=False, **{"expandedDict":"xxx"}) content',
'<div expandedDict="xxx" keywordArgument="xxx" positionalDict="xxx">content</div>\n'
)


def test_unicode_arguments(self):
self.assertHTML(
u'%(a=u"España") content',
u'<div a="España">content</div>\n'
)

0 comments on commit 07532b3

Please sign in to comment.