Grav / Twig - 过滤摘要以删除降价格式

时间:2018-01-30 05:07:26

标签: twig grav

我想使用{{ page.summary }}作为帖子首页索引的摘要。 但是我发现summary提供Markdown,所以如果帖子以标题开头:

 # Header 1

 Lorem ipsum dolor sit amet, consectetur adipiscing elit. 
 Quisque aliquam erat velit, ut semper mauris cursus consectetur. 
 Maecenas auctor vitae sapien vel porta. Orci varius natoque 
 penatibus et magnis dis parturient montes, nascetur ridiculus mus. 
 In eu turpis a lorem malesuada feugiat in id mi. Vivamus convallis dui

我会得到格式正确的标题1,而我希望以常规纯文本形式提供摘要。

是否有任何枝条过滤器可以做到这一点?

1 个答案:

答案 0 :(得分:2)

没有原生过滤器/功能但你肯定能找到一些捆绑

https://github.com/aptoma/twig-markdown

{% markdown %}
This is a list that is indented to match the context around the markdown tag:

* List item 1
* List item 2
    * Sub List Item
        * Sub Sub List Item

The following block will be transformed as code, as it is indented more than the
surrounding content:

    $code = "good";

{% endmarkdown %}