我正在尝试截断post.excerpt。
实际代码是<%- post.excerpt || post.content%>
上面显示了博客帖子的所有介绍文本。
现在我想将介绍文本截断为25个字符长度。
截断代码如下例所示:
<%- truncate('And they found that many people were sleeping better.', {length: 25, omission: '... (continued)'}) %>`现在结合这两点,我想到了:
<%- truncate((post.excerpt), {length: 25, omission: '... (continued)'}) || post.content%> 但这并不起作用,如何使截断工作满足我的需求?
完整的代码在这里...
<section class="article typo">
<%- post.excerpt || post.content %>
<% if (post.excerpt) { %>
<div class="readmore">
<a href="<%- url_for(post.path) %>">Read More</a>
</div>
<% } %>发布于 2017-08-05 21:44:09
不是将内容截断为摘录,而是尝试执行以下操作
`<section class="article typo">
<%- post.content | truncatewords: 25 %>
<div class="readmore">
<a href="<%- url_for(post.path) %>">Read More</a>
</div>
<% } %>`https://stackoverflow.com/questions/45522339
复制相似问题