New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

new <%namespace:defname> syntax doesn't handle multibyte chars #99

Closed
sqlalchemy-bot opened this Issue Jan 27, 2009 · 7 comments

Comments

Projects
None yet
1 participant
@sqlalchemy-bot

sqlalchemy-bot commented Jan 27, 2009

Migrated issue, originally created by Michael Bayer (@zzzeek)

# coding: utf-8
from mako.template import Template

t = Template("""# coding: utf-8

<%def name="my_def(x)">
    x is: ${x}
</%def>

## old way 
${my_def(u'drôle de petit voix m’a réveillé')}

## new way
<%self:my_def x='drôle de petit voix m’a réveillé'/>

## workaround
<%self:my_def x="${u'drôle de petit voix m’a réveillé'}"/>

""")

print t.render_unicode().encode('utf-8')

Attachments: patch.txt

@sqlalchemy-bot

This comment has been minimized.

sqlalchemy-bot commented Jan 27, 2009

Anonymous wrote:

The patch attached fixed the problem for me. Several lexer related unit tests fail after the patch though, but they seem to test for a specific internal state, which is affected by this patch so it doesn't necessarily mean anything.

@sqlalchemy-bot

This comment has been minimized.

sqlalchemy-bot commented Jul 19, 2009

Michael Bayer (@zzzeek) wrote:

the patch does not fix:

# coding: utf-8

from mako.template import Template

t = Template("""# coding:utf-8
<%def name="test(value)">
${value}
</%def>
øæå
<%self:test value="øæå" />
${self.test(value=u"øæå")}
""")
print t.render_unicode().encode('utf-8')

the output is incorrect.

@sqlalchemy-bot

This comment has been minimized.

sqlalchemy-bot commented Jan 20, 2010

Changes by Michael Bayer (@zzzeek):

  • set milestone to "0.3"
@sqlalchemy-bot

This comment has been minimized.

sqlalchemy-bot commented Mar 2, 2010

Michael Bayer (@zzzeek) wrote:

attached is a patch that actually works with file/module- based templates as well as python 2.4. I still would like to attempt reducing the points at which we are aware of unicode/string/bytes in this recipe. The "native unicode" mode makes it quite difficult to achieve. While native unicode mode is obviously out the window in python 3, I'd still like to make the source have an absolute minimum of encoding touchpoints so that the Py3k procedure will be very smooth.

@sqlalchemy-bot

This comment has been minimized.

sqlalchemy-bot commented Mar 2, 2010

Changes by Michael Bayer (@zzzeek):

  • removed labels: lexer
  • added labels: compiler
@sqlalchemy-bot

This comment has been minimized.

sqlalchemy-bot commented Mar 2, 2010

Michael Bayer (@zzzeek) wrote:

004aca5

@sqlalchemy-bot

This comment has been minimized.

sqlalchemy-bot commented Mar 2, 2010

Changes by Michael Bayer (@zzzeek):

  • changed status to closed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment