3
在Liquid,我知道你能做到 {% content | truncate:64 %}
截斷64個字符,{% content | truncatewords:100 %}
截斷100個字,但有什麼辦法由段落給定數目截斷?液體模板:截斷n個段落的
在Liquid,我知道你能做到 {% content | truncate:64 %}
截斷64個字符,{% content | truncatewords:100 %}
截斷100個字,但有什麼辦法由段落給定數目截斷?液體模板:截斷n個段落的
我有類似的問題。也許你可以這樣做:
{% assign truncatedContent = '' %}
{% assign paragraphs = post.content | split:'</p>' %}
{% for paragraph in paragraphs limit:N %}
{{ truncatedContent | append: paragraph }}
{{ truncatedContent | append: '</p>' }}
{% endfor %}
希望它有幫助。
絕對地點,很好的一個。 – Bolster