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
Copy file name to clipboardExpand all lines: readme.md
+9-12Lines changed: 9 additions & 12 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,11 +2,9 @@
2
2
3
3
# Razor Blade v1.0 stable
4
4
5
-
A library of common functions for Razor, to lighten Razor templates and make work easier.
5
+
A library of common functions for Razor, to lighten Razor templates and make work easier. Some examples:
6
6
7
-
The goal is to provide helpers for very common code snippets or functions, which would lighten the load. Here some common examples...
8
-
9
-
_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:_
7
+
_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:_
10
8
11
9
```razor
12
10
@* just cut it off at the visible character count, not splitting words *@
@@ -19,27 +17,26 @@ _Sometimes you need the first 100 characters followed by an ellipsis (if truncat
19
17
@Text.Ellipsis(Tags.Strip(longText), 100)
20
18
```
21
19
22
-
_Or sometimes you need a value, but if it's empty, you need another one. So instead of writing:_
20
+
_You need a value, but if it's empty (null, spaces, line-breaks, ` ` etc.), you need another one:_
23
21
24
22
```razor
23
+
@* Do this *@
24
+
@Text.First(firstName, "nothing found");
25
+
26
+
@* instead of this *@
25
27
@if(String.IsNullOrWhiteSpace(firstName as string)) {
26
28
@"nothing found"
27
29
} else {
28
30
@firstName
29
31
}
30
32
```
31
33
32
-
_You can write this, or below it the example with even more values:_
34
+
_Note that HTML whitespace like ` ` will also be treated as empty, unless you add `false` as a last parameter. But RazorBlade does more than just skip empty texts, here some more examples:_
_Note that HTML whitespace like ` ` will also be treated as empty, unless you add `false` as a last parameter. But RazorBlade does more than just skip empty texts, here some more examples:_
0 commit comments