Skip to content

Lektor Sitemaps incompatible with Jinja2 2.9 #343

@freakboy3742

Description

@freakboy3742

Using Lektor 2.3; If you have a project with a sitemap (using the template suggested by the Lektor docs):

<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
  {%- for page in [site.root] if page != this recursive %}
  <url><loc>{{ page|url(external=true) }}</loc></url>
  {{- loop(page.children) }}
  {%- endfor %}
</urlset>

and you have jinja2 2.9 - 2.9.3, in your environment, you get a build error:

(lektor) hammer:pybee.org rkm$ lektor build
Started build
U ar_AR/sitemap.xml
E ar_AR/sitemap.xml (NameError: free variable 'l_1_this' referenced before assignment in enclosing scope)
U sitemap.xml
E sitemap.xml (NameError: free variable 'l_1_this' referenced before assignment in enclosing scope)
U pt_BR/sitemap.xml
E pt_BR/sitemap.xml (NameError: free variable 'l_1_this' referenced before assignment in enclosing scope)
U zh_TW/sitemap.xml
E zh_TW/sitemap.xml (NameError: free variable 'l_1_this' referenced before assignment in enclosing scope)

Downgrading to Jinja2 2.8.1 seems to resolve the problem.

I'm guessing either the docs need to be updated to reflect a required change in the sitemap template, or there's a bug in Jinja2.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions