tera icon indicating copy to clipboard operation
tera copied to clipboard

Added substr, find and rfind

Open adrianboston opened this issue 5 months ago • 0 comments

Added substr, find and rfind into src/builtsin/filters/string.rs

Substr motivated by providing a descriptive href link opposed to the common ...more.

Used as such with Zola

{{page.content | striptags | substr(begin = 0, length=300) | safe}}
<a href="{{ page.permalink | safe }}{%- if config.extra.uglyurls %}index.html{%- endif %}">{{page.content | striptags | substr(begin = 300, length=30) | safe}}...</a>

find and rfind used to facilitate ending on a word end or period in the link rfind(" ") or rfind(".")

Tests included for all also within string.rs

adrianboston avatar Aug 07 '25 18:08 adrianboston