Lektor Pagination - TemplateSyntaxError: Encountered unknown tag 'endblock'
Lektor Pagination - TemplateSyntaxError: Encountered unknown tag 'endblock'
使用 Lektor,我创建了一个模型 book
作为 books
模型的子模型(类似于 blog-post
和 blog
模型)。
/books/
页面正确生成,底部有分页。当我转到第二页时,它抛出了这个奇怪的错误。
Build Failure :'(
Building of the artifact “books/page/2/index.html” failed. This is what we know about the problem:
Traceback (most recent call last):
File "/home/anand/.virtualenvs/exp/lib/python2.7/site-packages/lektor/builder.py", line 702, in update
yield ctx
File "/home/anand/.virtualenvs/exp/lib/python2.7/site-packages/lektor/builder.py", line 924, in build_artifact
build_func(artifact)
File "/home/anand/.virtualenvs/exp/lib/python2.7/site-packages/lektor/build_programs.py", line 169, in build_artifact
self.source['_template'], this=self.source)
File "/home/anand/.virtualenvs/exp/lib/python2.7/site-packages/lektor/builder.py", line 592, in render_template_into
this=this, **extra)
File "/home/anand/.virtualenvs/exp/lib/python2.7/site-packages/lektor/environment.py", line 466, in render_template
return self.jinja_env.get_or_select_template(name).render(ctx)
File "/home/anand/.virtualenvs/exp/lib/python2.7/site-packages/jinja2/environment.py", line 851, in get_or_select_template
return self.get_template(template_name_or_list, parent, globals)
File "/home/anand/.virtualenvs/exp/lib/python2.7/site-packages/jinja2/environment.py", line 812, in get_template
return self._load_template(name, self.make_globals(globals))
File "/home/anand/.virtualenvs/exp/lib/python2.7/site-packages/lektor/environment.py", line 194, in _load_template
rv = jinja2.Environment._load_template(self, name, globals)
File "/home/anand/.virtualenvs/exp/lib/python2.7/site-packages/jinja2/environment.py", line 786, in _load_template
template = self.loader.load(self, name, globals)
File "/home/anand/.virtualenvs/exp/lib/python2.7/site-packages/jinja2/loaders.py", line 125, in load
code = environment.compile(source, name, filename)
File "/home/anand/.virtualenvs/exp/lib/python2.7/site-packages/jinja2/environment.py", line 565, in compile
self.handle_exception(exc_info, source_hint=source_hint)
File "/home/anand/.virtualenvs/exp/lib/python2.7/site-packages/jinja2/environment.py", line 754, in handle_exception
reraise(exc_type, exc_value, tb)
File "/home/anand/projects/python/projectchalam/templates/books.html", line 13, in template
{% endblock %}
TemplateSyntaxError: Encountered unknown tag 'endblock'.
这里是books.html
{% extends "base.html" %}
{% from "macros/pagination.html" import render_pagination %}
{% block title %}Books{% endblock %}
{% block content %}
<ul class="blog-index">
{% for post in this.pagination.items %}
<h2>
<a href="{{ post|url }}">
{{ post.title }}
</a>
</h2>
{% endfor %}
</ul>
<div style="padding-left: 45px;">
{% if this.pagination.pages > 1 %}
{{ render_pagination(this.pagination) }}
{% endif %}
</div>
{% endblock %}
我在 books.html 的第 13 行中没有 {% endblock %}
,如回溯所示。
如果您使用的是 Lektor 1(当前发布的版本),不幸的是有时会缓存语法错误。清除 lektor 缓存以查看是否可以解决问题(您可以使用 lektor clean
.
使用 Lektor,我创建了一个模型 book
作为 books
模型的子模型(类似于 blog-post
和 blog
模型)。
/books/
页面正确生成,底部有分页。当我转到第二页时,它抛出了这个奇怪的错误。
Build Failure :'(
Building of the artifact “books/page/2/index.html” failed. This is what we know about the problem:
Traceback (most recent call last):
File "/home/anand/.virtualenvs/exp/lib/python2.7/site-packages/lektor/builder.py", line 702, in update
yield ctx
File "/home/anand/.virtualenvs/exp/lib/python2.7/site-packages/lektor/builder.py", line 924, in build_artifact
build_func(artifact)
File "/home/anand/.virtualenvs/exp/lib/python2.7/site-packages/lektor/build_programs.py", line 169, in build_artifact
self.source['_template'], this=self.source)
File "/home/anand/.virtualenvs/exp/lib/python2.7/site-packages/lektor/builder.py", line 592, in render_template_into
this=this, **extra)
File "/home/anand/.virtualenvs/exp/lib/python2.7/site-packages/lektor/environment.py", line 466, in render_template
return self.jinja_env.get_or_select_template(name).render(ctx)
File "/home/anand/.virtualenvs/exp/lib/python2.7/site-packages/jinja2/environment.py", line 851, in get_or_select_template
return self.get_template(template_name_or_list, parent, globals)
File "/home/anand/.virtualenvs/exp/lib/python2.7/site-packages/jinja2/environment.py", line 812, in get_template
return self._load_template(name, self.make_globals(globals))
File "/home/anand/.virtualenvs/exp/lib/python2.7/site-packages/lektor/environment.py", line 194, in _load_template
rv = jinja2.Environment._load_template(self, name, globals)
File "/home/anand/.virtualenvs/exp/lib/python2.7/site-packages/jinja2/environment.py", line 786, in _load_template
template = self.loader.load(self, name, globals)
File "/home/anand/.virtualenvs/exp/lib/python2.7/site-packages/jinja2/loaders.py", line 125, in load
code = environment.compile(source, name, filename)
File "/home/anand/.virtualenvs/exp/lib/python2.7/site-packages/jinja2/environment.py", line 565, in compile
self.handle_exception(exc_info, source_hint=source_hint)
File "/home/anand/.virtualenvs/exp/lib/python2.7/site-packages/jinja2/environment.py", line 754, in handle_exception
reraise(exc_type, exc_value, tb)
File "/home/anand/projects/python/projectchalam/templates/books.html", line 13, in template
{% endblock %}
TemplateSyntaxError: Encountered unknown tag 'endblock'.
这里是books.html
{% extends "base.html" %}
{% from "macros/pagination.html" import render_pagination %}
{% block title %}Books{% endblock %}
{% block content %}
<ul class="blog-index">
{% for post in this.pagination.items %}
<h2>
<a href="{{ post|url }}">
{{ post.title }}
</a>
</h2>
{% endfor %}
</ul>
<div style="padding-left: 45px;">
{% if this.pagination.pages > 1 %}
{{ render_pagination(this.pagination) }}
{% endif %}
</div>
{% endblock %}
我在 books.html 的第 13 行中没有 {% endblock %}
,如回溯所示。
如果您使用的是 Lektor 1(当前发布的版本),不幸的是有时会缓存语法错误。清除 lektor 缓存以查看是否可以解决问题(您可以使用 lektor clean
.