gpt4 book ai didi

液体模板 : Truncate N paragraphs

转载 作者:行者123 更新时间:2023-12-02 06:49:23 26 4
gpt4 key购买 nike

Liquid ,我知道你可以做到{% 内容 | truncate:64 %} 截断 64 个字符和 {% content | truncatewords:100 %} 截断 100 个单词,但是有没有办法按给定数量的段落进行截断?

最佳答案

我也有类似的问题。也许你可以做这样的事情:

{% assign truncatedContent = '' %}
{% assign paragraphs = post.content | split:'</p>' %}
{% for paragraph in paragraphs limit:N %}
{{ truncatedContent | append: paragraph }}
{{ truncatedContent | append: '</p>' }}
{% endfor %}

希望有帮助。

关于液体模板 : Truncate N paragraphs,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21161918/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com