U4-10135 - Umbraco Helper truncate by number of words

Created by Richard Thompson 10 Jul 2017, 12:11:36 Updated by Shannon Deminick 12 Sep 2017, 03:37:37

Subtask of: U4-9609

The Umbraco Helper has a truncate method to allow you to truncate content to a particular number of characters. I think it would be useful to have an alternative method that truncates the content to a specified number of words.


Stephan 12 Jul 2017, 09:07:51

Assuming this is the code to be reviewed? PR: https://github.com/umbraco/Umbraco-CMS/pull/2043

Robert Copilau 12 Jul 2017, 09:41:31

That's right Stephan, I'm the new guy, still getting the hang of it :).

Claus Jensen 12 Jul 2017, 10:02:04

Have added some comments to the PR on github

Robert Copilau 31 Aug 2017, 09:50:42


Changes: *Changed from the String object qualifier to type qualifier *Added HtmlSanitization package *Added check for invalid HTML and sanitation on WordsToLength and Truncate methods, sanitation result is not pretty, it most of the cases some text is removed for the sake of keeping the HTML valid. *Added some extra comments

Shannon Deminick 01 Sep 2017, 06:13:09

Hrm, this is a lot of extra overhead for this single problem. Now we will be shipping 2 extra assemblies and dependencies simply to truncate words which we don't want to do. How come we need these extra dependencies all of a sudden?

Robert Copilau 03 Sep 2017, 19:23:35

PR: https://github.com/umbraco/Umbraco-CMS/pull/2043

Changes: *Reverted back to previous commit to simplify things *Added invalid html check to avoid infinite loop

Robert Copilau 06 Sep 2017, 10:40:22


Shannon Deminick 12 Sep 2017, 03:37:33

Whohoo! Good work, good tests, all pass :)

Priority: Normal

Type: Feature (request)

State: Fixed


Difficulty: Normal


Backwards Compatible: True

Fix Submitted:

Affected versions: 7.6.3, 7.6.4, 7.6.5

Due in version: 7.6.7

Sprint: Sprint 67

Story Points: 1