Jam*_*ran 19 liquid-layout liquid jekyll github-pages
我在我的博客上使用GitHub页面,并且遇到了Jekyll的问题.我的post.html有一个这样的块:
{% for testpost in site.posts %}
{% four %}
{% lines of %}
{% processing %}
{% goes here %}
{% endfor %}
Run Code Online (Sandbox Code Playgroud)
中间的部分并不重要.重要的部分是在{% %}标记之外的行的结尾,因此被渲染到html中.由于这是一个循环,它在HTML页面的中间放置了大约1000个空白行.它不会影响显示,但会造成View/Source的麻烦.
关于如何避免这些额外空白线的任何想法?
小智 13
有一个很好的解决方法,我在https://github.com/plusjade/jekyll-bootstrap/blob/master/_includes/JB/setup中找到,并且与github页面兼容.
只需将循环包含在捕获语句中,并将nil分配给生成的var.
{% capture cache %}
{% for p in site.posts %}
do stuff here
{% endfor %}
{% endcapture %}{% assign cache = nil %}
Run Code Online (Sandbox Code Playgroud)
小智 8
由于Liquid v4(包含在Jekyll从v3.5)有一个Whitespace control,这最后用空行,白空间等情况下解决
链接到文档:https://shopify.github.io/liquid/basics/whitespace/
怎么样
{{ page.content | escape | strip_newlines }}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
5378 次 |
| 最近记录: |