Skip to content
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

%% not working when not at the beginning of the line #323

Closed
pjadzinsky opened this issue Aug 6, 2020 · 7 comments
Closed

%% not working when not at the beginning of the line #323

pjadzinsky opened this issue Aug 6, 2020 · 7 comments

Comments

@pjadzinsky
Copy link

pjadzinsky commented Aug 6, 2020

Hello,

Thanks for developing and maintaining a great package.

I have a template that looks like this

# -*- coding: utf-8 -*-
%%pip install package
if <some condition>:
    %%pip install <some other package>

This gets rendered into

# -*- coding: utf-8 -*-
%pip install package
if <some condition>:
    %%pip install <some other package>

where the last line starts with (some spaces) + %%

Trying to template

# -*- coding: utf-8 -*-
%%pip install package
if <some condition>:
    %pip install <some other package>

Raises
Thanks again

@zzzeek
Copy link
Member

zzzeek commented Aug 6, 2020

hi

these must be escaped as mentioned at https://docs.makotemplates.org/en/latest/syntax.html#control-structures

so in this case you'd want %%%

@zzzeek
Copy link
Member

zzzeek commented Aug 6, 2020

I don't know what's up with the second one, might be a bug, but Mako is not maintained right now (unless someone wants to wriet a PR w/ tests).

try a literal block


t = Template("""
# -*- coding: utf-8 -*-
%%%pip install package
if <some condition>:
    ${"%"}pip install <some other package>

""")

@pjadzinsky
Copy link
Author

Thanks for the reply

@sqla-tester
Copy link
Collaborator

Hai Zhu has proposed a fix for this issue in the main branch:

fix percent escape not working when not at the beginning of the line https://gerrit.sqlalchemy.org/c/sqlalchemy/mako/+/5111

@zzzeek
Copy link
Member

zzzeek commented Jan 25, 2024

I've reverted in edf44dc and revoked 1.3.1. This issue remains un-fixed

@zzzeek zzzeek reopened this Jan 25, 2024
@sqla-tester
Copy link
Collaborator

Hai Zhu has proposed a fix for this issue in the main branch:

fix percent escape not working when not at the beginning of the line https://gerrit.sqlalchemy.org/c/sqlalchemy/mako/+/5141

@zzzeek
Copy link
Member

zzzeek commented Jan 30, 2024

1.3.2 is released thanks again, will revisit here if further problems

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants