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

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

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

Awesome. Here's what I finally rested on:

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

http://twig.sensiolabs.org/doc/filters/slice.html

or

http://twig.sensiolabs.org/doc/extensions/text.html

Last updated

Try to use Twig extensions plugin with truncate filter:

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

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

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.