This forum has moved to a new location and is in read-only mode. Please visit talk.octobercms.com to access the new location.

clone458396
clone458396

I need to truncate some dynamic content within a page. Here's my code thus far:

{{ testimonial.content|raw }}

How would I truncate the testimonial to, say, 200 characters?

Thanks, Bret

Last updated

craw
craw

{{ testimonial.content | slice(0, 200) }} not tested

clone458396
clone458396

Awesome. Here's what I finally rested on:

{{ testimonial.content|slice(0,200)|raw }}
Daniel81
Vojta Svoboda
Vojta Svoboda

Try to use Twig extensions plugin with truncate filter:

{{ "Hello World!" | truncate(5) }}

There is also uppercase, lowercase, ucfirst, lcfirst filters.

abdullah.maswadeh15560
abdullah.maswadeh15560

This works for me :

{{ str_limit('Hello World ! , 5 ') }}

Last updated

1-6 of 6

You cannot edit posts or make replies: the forum has moved to talk.octobercms.com.