You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
/// Cut off a text at the best possible place with a max-length.
9
+
/// This will count html-entities like & or umlauts as 1 character,
10
+
/// and will try to cut off between words if possible.
11
+
/// </summary>
12
+
/// <param name="value">String to cut off. Can contain umlauts and html-entities, but should not contain html-tags as there are not treated properly.</param>
13
+
/// <param name="length">length to cut off at</param>
Copy file name to clipboardExpand all lines: Blade/Blade/Text/Ellipsis.cs
-12Lines changed: 0 additions & 12 deletions
Original file line number
Diff line number
Diff line change
@@ -4,18 +4,6 @@ namespace Connect.Razor.Blade
4
4
{
5
5
publicstaticpartialclassText
6
6
{
7
-
/// <summary>
8
-
/// Cut off a text at the best possible place with a max-length.
9
-
/// This will count html-entities like & or umlauts as 1 character,
10
-
/// and will try to cut off between words if possible.
11
-
/// </summary>
12
-
/// <param name="value">String to cut off. Can contain umlauts and html-entities, but should not contain html-tags as there are not treated properly.</param>
13
-
/// <param name="length">length to cut off at</param>
14
-
/// <returns></returns>
15
-
publicstaticstringCrop(stringvalue,intlength)
16
-
{
17
-
returnTruncator.SafeTruncate(value,length);
18
-
}
19
7
20
8
/// <summary>
21
9
/// Crop a text if too long, add in that case, also add an ellipsis or a custom suffix
Copy file name to clipboardExpand all lines: README.md
+9-3Lines changed: 9 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -10,7 +10,11 @@ The goal is to provide helpers for very common code snippets or functions, which
10
10
_Sometimes you need the first 100 characters followed by an ellipsis (if truncated), but umlauts like `ü` will mess up your count or might even be cut off. This is automatically handled by:_
11
11
12
12
```razor
13
+
@* just cut it off at the visible character count, not splitting words *@
13
14
@Text.Crop(someText, 100)
15
+
16
+
@* truncate a text and if necessary, add ellipsis character *@
17
+
@Text.Ellipsis(longText, 100)
14
18
```
15
19
16
20
_Or sometimes you need a value, but if it's empty, you need another one. So instead of writing:_
@@ -37,9 +41,6 @@ _Note that HTML whitespace like ` ` will also be treated as empty, unless y
37
41
@* remove html from a wysiwyg-string *@
38
42
@Tags.Remove(formattedText)
39
43
40
-
@* truncate a text and if necessary, add ellipsis character *@
41
-
@Text.Ellipsis(longText, 100)
42
-
43
44
@* the same with a custom ending *@
44
45
@Text.Ellipsis(longText, 100, "...more")
45
46
@@ -72,6 +73,7 @@ This is a short summary of the most used variations of the helpers. Further deta
72
73
1.`Text.Ellipsis(value, length)`
73
74
1.`Text.Has(value)`
74
75
1.`Text.First(value, value[, moreValues, ...])`
76
+
1.`Text.Zip(value)`
75
77
76
78
## Commands in v0.1 to Shorten Texts Correctly
77
79
@@ -95,6 +97,10 @@ This is a short summary of the most used variations of the helpers. Further deta
95
97
96
98
1.`Text.First(intendedValue, next-value, next-value, [up to 5 values], false)` - same behavior as above, values will be checked in the order given. By ending with `false` html-whitespace will not be cleaned but treated as text.
97
99
100
+
### Commands to Clean up Text
101
+
102
+
1.`Text.Zip(value)` will remove line-breaks and shrink all multiple-spaces into one single space.
103
+
98
104
## Commands in v0.1 to Convert Html to Text or Back
99
105
100
106
1.`Tags.Remove(htmlText)` - strips the html from an string, ensuring that all tags will cause 1 spaces between words, but only one (multiple spaces are shortened to 1 again)
0 commit comments