Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[String] Allow to keep the last word when truncating a text #35649

Merged
merged 1 commit into from
Feb 21, 2020
Merged

[String] Allow to keep the last word when truncating a text #35649

merged 1 commit into from
Feb 21, 2020

Conversation

franmomu
Copy link
Contributor

@franmomu franmomu commented Feb 8, 2020

Q A
Branch? master
Bug fix? no
New feature? yes
Deprecations? no
Tickets Fix #35567
License MIT
Doc PR -

The truncate filter from twig/extensions has a preserve parameter to preserve whole words.

Since twig/extensions is deprecated and its alternative for truncate filter is the use of u filter, this PR adds preverse word functionality.

Copy link
Member

@nicolas-grekas nicolas-grekas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good to go on my side thanks.
I updated the implementation a bit and renamed the argument to $cut instead, as that looked consistent with wordwrap() to me.

@fabpot
Copy link
Member

fabpot commented Feb 21, 2020

Thank you @franmomu.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[String] Add preserve parameter to truncate method
5 participants