当我在Windows 10上运行命令bundle exec jekyll serve --trace
时,我收到以下错误:
液体例外:Liquid语法错误(第8行):“for循环”中的语法错误-有效语法:for [item] in [collection] in 2018-09-14-在jinja2.markdown jekyll 3.7.3中渲染Python字典|错误:Liquid语法错误(第8行):“for循环”中的语法错误-有效语法:在[集合]中的[项目]
有人知道如何解决这个问题吗?
文件2018-09-14-在jinja2.markdown中渲染python dict内容为:
---
layout: post
title: "Rendering a python dict in jinja2"
date: 2018-09-14 00:01:57 +0800
categories: python jinja2
---
```python
url_list = [{'target': 'http://10.58.48.103:5000/', 'clicks': '1'},
{'target': 'http://slash.org', 'clicks': '4'},
{'target': 'http://10.58.48.58:5000/', 'clicks': '1'},
{'target': 'http://de.com/a', 'clicks': '0'}]
#Python 2.7
{% for key, value in url_list.iteritems() %}
<li>{{ value["target"] }}</li>
{% endfor %}
#Python 3
{% for key, value in url_list.items() %}
<li>{{ value["target"] }}</li>
{% endfor %}
```
2条答案
按热度按时间qmb5sa221#
Liquid会尝试处理你的源代码,特别是jinja2控件标签,你需要告诉Liquid避免使用
raw
标签处理它:vq8itlhq2#
1 -
{% raw %}
标记是this post和this post中python代码解决方案的一部分。2 -解的另一部分can be a bug in the way Jekyll manages excerpts。
删除代码中的空行,它就会工作。