有没有办法从 Nunjucks 模板语言中的字符串中获取子字符串?

Is there any way to get a substring from a string in Nunjucks templating language?

如果我们有值'cats',我想要子字符串'at'(需要删除第一个和最后一个字母)。我们如何才能在 Nunjucks 模板中实现这一点?

您可以使用 JavaScript slice 方法执行此操作,如下所示:

{{cats.slice(1, -1)}}