# Tera question about truncate and strip the content

**URL:** <https://zola.discourse.group/t/tera-question-about-truncate-and-strip-the-content/1726>\
**Category:** Uncategorized\
**Created:** [April 19, 2023, 4:15pm UTC](https://zola.discourse.group/t/tera-question-about-truncate-and-strip-the-content/1726 "2023-04-19T16:15:52Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![adrianboston](https://yyz2.discourse-cdn.com/free1/user_avatar/zola.discourse.group/adrianboston/32/907_2.png) [@adrianboston](https://zola.discourse.group/u/adrianboston)\
**Post date:** [April 19, 2023, 4:15pm UTC](https://zola.discourse.group/t/tera-question-about-truncate-and-strip-the-content/1726/1 "2023-04-19T16:15:52Z")

</div>

We have the Tera builtin truncate function that is useful for providing the x number of characters in the paginated section.

> {{ page.content | truncate(length=100) }}

Is there a builtin that will strip out the first x characters. Cannot find one similar

> {{ page.content | strip(length=100) }}

And any known method or idea for truncating to the end of a word rather than a charac…

---

<div class="post-metadata">

**Author:** ![notpeter](https://yyz2.discourse-cdn.com/free1/user_avatar/zola.discourse.group/notpeter/32/1015_2.png) [@notpeter](https://zola.discourse.group/u/notpeter)\
**Post date:** [June 20, 2023, 5:00am UTC](https://zola.discourse.group/t/tera-question-about-truncate-and-strip-the-content/1726/2 "2023-06-20T05:00:16Z")

</div>

To me, this seems like a potential useful feature, but I wouldn’t call it `strip` as I think it would be confused for the existing `trim` filter.

One could probably implement an optional `start` argument to the existing truncate filter – truncation is also the correct verb for left trimming too, not just right trimming. So it’d be something like this:

> {{ value | truncate(start=50, length=100) }}

Of course, then it’d be confusing API if `start` was an int and `end` was a string – maybe deprecate `end` and offer new `prefix` / `suffix` arguments for when you use characters other than “…”.

Alternatively a more general like `substring` could be quite useful too:

> #### substring
> 
> returns a substring given `start` and `end` parameters. Both parameters are optional an omitting them returns the same string.
> 
> > {{ value | substring(start=100) }}

Either way, the [Tera project github](https://github.com/Keats/tera/issues) is probably the right place to file an issue as Zola is but [one of many](https://crates.io/crates/tera/reverse_dependencies) projects using Tera for templating.

---

<div class="post-metadata">

**Author:** ![adrianboston](https://yyz2.discourse-cdn.com/free1/user_avatar/zola.discourse.group/adrianboston/32/907_2.png) [@adrianboston](https://zola.discourse.group/u/adrianboston)\
**Post date:** [February 24, 2024, 2:39am UTC](https://zola.discourse.group/t/tera-question-about-truncate-and-strip-the-content/1726/3 "2024-02-24T02:39:52Z")

</div>

> [@notpeter](#):
>
> {{ value | truncate(start=50, length=100) }}

start and length is ideal.  
Yeah thats fine. substr, trunc or anything. I need it.
