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

Jinja2-2.9 and Python3 generate <generator> tag #645

Closed
tk0miya opened this issue Jan 8, 2017 · 7 comments

Comments

@tk0miya
Copy link

commented Jan 8, 2017

With 2.9, 2.9.1 and 2.9.2, Jinja2 generates <generator> tag for macro having blocks.

Example code:

import sys
import jinja2
from jinja2 import Template

template = """
{%- macro hello() %}
  Hello, {% block name %}jinja2{% endblock %}!
{%- endmacro %}
{{ hello() }}
"""

Result:

Python vesion: 3.5.2 (default, Oct 11 2016, 17:23:55)
[GCC 4.2.1 Compatible Apple LLVM 7.3.0 (clang-703.0.31)]
Jinja2 vesion: 2.9.2

<generator object macro at 0x10ffe2468>

But this works fine on python2.7.

Python vesion: 2.7.13 (default, Dec 20 2016, 13:27:09)
[GCC 4.2.1 Compatible Apple LLVM 7.3.0 (clang-703.0.31)]
Jinja2 vesion: 2.9.2


  Hello, jinja2!

Note: result of 2.8 and py27, py35.

Python vesion: 2.7.13 (default, Dec 20 2016, 13:27:09)
[GCC 4.2.1 Compatible Apple LLVM 7.3.0 (clang-703.0.31)]
Jinja2 vesion: 2.8.1


  Hello, jinja2!
Python vesion: 3.5.2 (default, Oct 11 2016, 17:23:55)
[GCC 4.2.1 Compatible Apple LLVM 7.3.0 (clang-703.0.31)]
Jinja2 vesion: 2.8.1


  Hello, jinja2!
@mitsuhiko

This comment has been minimized.

Copy link
Member

commented Jan 8, 2017

What does it even mean to have a {% block %} inside a macro O_O.

@mitsuhiko mitsuhiko closed this in 6f7fa5c Jan 8, 2017

@mitsuhiko

This comment has been minimized.

Copy link
Member

commented Jan 8, 2017

It does the same now it did in earlier versions however I'm surprised this does something useful.

@cdeil

This comment has been minimized.

Copy link

commented Jan 8, 2017

@mitsuhiko - Thanks for fixing it. Could you please make a patch release soon?

This issue is affecting other Sphinx projects, e.g. the sidebar from the Astropy docs disappeared recently and it took me some time to find this issue:
astropy/astropy#5679 (comment)
It's particularly nasty since there's no warning or error from Sphinx, but the generated HTML is corrupted.

@mitsuhiko

This comment has been minimized.

Copy link
Member

commented Jan 8, 2017

Yes, there will be another one tonight. I just want to see if there is not anything else creeping up.

@cdeil

This comment has been minimized.

Copy link

commented Jan 8, 2017

Great, thank you!

@mitsuhiko

This comment has been minimized.

Copy link
Member

commented Jan 8, 2017

Release is out now.

@tk0miya

This comment has been minimized.

Copy link
Author

commented Jan 9, 2017

I confirmed it works fine :-)
Thank you for quick fix!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.