好吧,这可能是一个愚蠢的问题,但我想知道是否有任何方法可以在 Jekyll 中生成标记来保留 Liquid-tag 的缩进。如果无法解决,世界就不会结束。我只是好奇,因为我喜欢我的代码看起来整洁,即使编译。:)
例如我有这两个:
base.html:
<body>
<div id="page">
{{content}}
</div>
</body>
索引.md:
---
layout: base
---
<div id="recent_articles">
{% for post in site.posts %}
<div class="article_puff">
<img src="/resources/images/fancyi.jpg" alt="" />
<h2><a href="{{post.url}}">{{post.title}}</a></h2>
<p>{{post.description}}</p>
<a href="{{post.url}}" class="read_more">Read more</a>
</div>
{% endfor %}
</div>
问题是导入的 {{content}}-tag 是在没有上面使用的缩进的情况下呈现的。
所以而不是
<body>
<div id="page">
<div id="recent_articles">
<div class="article_puff">
<img src="/resources/images/fancyimage.jpg" alt="" />
<h2><a href="/articles/2012/11/14/gettin-down-with-rwd.html">Gettin' down with responsive web design</a></h2>
<p>Everyone's talking about it. Your client wants it. You need to code it.</p>
<a href="/articles/2012/11/14/gettin-down-with-rwd.html" class="read_more">Read more</a>
</div>
</div>
</div>
</body>
我明白了
<body>
<div id="page">
<div id="recent_articles">
<div class="article_puff">
<img src="/resources/images/fancyimage.jpg" alt="" />
<h2><a href="/articles/2012/11/14/gettin-down-with-rwd.html">Gettin' down with responsive web design</a></h2>
<p>Everyone's talking about it. Your client wants it. You need to code it.</p>
<a href="/articles/2012/11/14/gettin-down-with-rwd.html" class="read_more">Read more</a>
</div>
</div>
</div>
</body>
似乎只有第一行正确缩进。其余的从行首开始......那么,多行液体模板导入?:)