Jekyll Liquid:对整个包含的文件使用truncatewords过滤器

时间:2017-11-24 16:50:53

标签: templates jekyll liquid

在Jekyll with Liquid中有一种方法,包含另一个文件并截断​​其中的单词数量吗?

{{ {% include intro.md %} | truncatewords: 3 }}

无论我如何设置花括号,都没有运气......

包括intro.md单独工作:

{% include intro_DE.md %}

这是一个vague note,包括在Jekyll下可能有点不同,但我仍然没有线索......

也许,我需要通过capture

1 个答案:

答案 0 :(得分:1)

我找到了捕获的解决方案。它不是很优雅:

{% capture foo %}{% include intro_DE.md %}{% endcapture %}
{{ foo | truncatewords: 20 }}

输出仍为markdown-ish(= good)。 “内联样式”,如粗体,下划线,删除线仍然有用。

### Headlines<html tags>不要。 (可能是因为这种技术杀死了换行符......)