terminal-labs / lektor-jinja-content

Render Lektor content fields with Jinja2.
Other
11 stars 5 forks source link

Jinja content not rendering correctly when using macros #18

Open leogzyl opened 1 year ago

leogzyl commented 1 year ago

I was trying out this plugin with the basic blog example from lektor quickstart and noticed that jinja content didn't work inside blog or blog post pages, but did work on the other pages.

Removing all macros from those pages, I can get jinja content to render correctly.

This doesn't work:

{% extends "layout.html" %}
{% from "macros/blog.html" import render_blog_post %}
{% from "macros/pagination.html" import render_pagination %}
{% block title %}{{ this.title }}{% endblock %}
{% block body %}
  {% for child in this.pagination.items %}
    {{ render_blog_post(child, from_index=true) }}
  {% endfor %}
  {{ render_pagination(this.pagination) }}
{% endblock %}

While this does:

{% extends "layout.html" %}
{% from "macros/blog.html" import render_blog_post %}
{% block title %}{{ this.title }}{% endblock %}
{% block body %}
  {% for child in this.pagination.items %}
    <a href="{{ child|url }}">{{ child.title }}</a>
  {% endfor %}
{% endblock %}

Is this a bug or something to be expected? Any other way to get macros to work?

nixjdm commented 1 year ago

I haven't tested this yet, but working through #19 there's a good chance this will be fixed as well.