babel can't extract text from template with "with" statement #668

Closed
zfdang opened this Issue Jan 18, 2013 · 10 comments

Comments

Projects
None yet
5 participants

zfdang commented Jan 18, 2013

my template has the following code:

{% with messages = get_flashed_messages() %}
  {% if messages %}
  <div class="alert alert-info">
    <a class="close" data-dismiss="alert">&times;</a>
    <ul>
    {% for message in messages %}
      <li>{{ message }}</li>
    {% endfor %}
    </ul>
  </div>
  {% endif %}
{% endwith %}

but pybabel can't extract text from this file unless I remove the {% with %} statement.

is there any mistake I made in this case?

Owner

untitaker commented Jan 21, 2013

Jinja2 doesn't have a with statement. This doesn't have anything to do with Flask or any plugins of it.

interru commented Jan 23, 2013

Jinja2 does have a with statement: http://jinja.pocoo.org/docs/templates/#with-statement ;)

Owner

untitaker commented Jan 23, 2013

I have no idea how i missed that. Sorry.

Owner

untitaker commented Jan 23, 2013

@Dantifer, do you still have this problem? Which errors do you get?

interru commented Jan 23, 2013

Did you use flask-babel and have you created a babel.cfg file which contents are similiar to the following?

[python: **.py]
[jinja2: **/templates/**.html]
extensions=jinja2.ext.autoescape,jinja2.ext.with_

zfdang commented Jan 24, 2013

yes, I have the babel.cfg file, but I did not add the extensions.
after adding the extensions, the with statement can work correctly now. so
it's my fault, but a bug.

thanks for your help!

On Wed, Jan 23, 2013 at 11:16 PM, Mathias Köhler
notifications@github.comwrote:

Did you use flask-babel http://packages.python.org/Flask-Babel/ and
have you created a babel.cfg file which contents are similiar to the
following:

[python: **.py]
[jinja2: /templates/.html]
extensions=jinja2.ext.autoescape,jinja2.ext.with_


Reply to this email directly or view it on GitHubhttps://github.com/mitsuhiko/flask/issues/668#issuecomment-12599676.

Regards!

Zhengfa

mitsuhiko closed this Jan 27, 2013

My application templates folder structure :

/templates
    /app
          /_layouts
                /main.html
                /email.html
    /website
          /_layouts
                /main.html

when I extract files, babel doesn't extract files which in templates/website/_layouts/main.html. If I change file name from templates/website/_layouts/main.html to templates/website/layouts/main.html babel extract this file.

babel.cfg

[python: **.py]
[jinja2: **/templates/**.html]
extensions=jinja2.ext.autoescape,jinja2.ext.with_
Owner

mitsuhiko commented Nov 3, 2015

I think babel ignores folders with leading underscores.

babel extract files in "templates/app/_parts/" but it doesn't extract files in "templates/app/_layouts/" and "templates/website/_layouts/". Does babel have a problem with "_layouts" word?

screen shot 2015-11-04 at 11 14 30

Owner

mitsuhiko commented Nov 4, 2015

Maybe you can make a testcase for this and open a new ticket.

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