使用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
来解决。
关于python - Lektor分页-TemplateSyntaxError:遇到未知标签“endblock”,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/35753101/