Skip to content

[String] Add preserve parameter to truncate method #35567

@franmomu

Description

@franmomu

Description

I was trying to replace the truncate filter from twig/extensions with the new u filter, but it looks like u.truncate doesn’t have a preserve option, is there a way to achieve the same thing? If not, I could add the parameter to the truncate method.

Example

With twig/extensions:

{{ "Hello World!"|truncate(7, true) }} // Hello World!

With u filter:

{{ "Hello World!"|u.truncate(7) }} // Hello W

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions