Skip to content

Commit cfe4fb0

Browse files
committed
docs
1 parent 48eded3 commit cfe4fb0

1 file changed

Lines changed: 9 additions & 12 deletions

File tree

readme.md

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,9 @@
22

33
# Razor Blade v1.0 stable
44

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:
66

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:_
108

119
```razor
1210
@* 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
1917
@Text.Ellipsis(Tags.Strip(longText), 100)
2018
```
2119

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:_
2321

2422
```razor
23+
@* Do this *@
24+
@Text.First(firstName, "nothing found");
25+
26+
@* instead of this *@
2527
@if(String.IsNullOrWhiteSpace(firstName as string)) {
2628
@"nothing found"
2729
} else {
2830
@firstName
2931
}
3032
```
3133

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:_
3335

3436
```razor
35-
@Text.First(firstName, "nothing found");
36-
37+
@* First non-empty of many possible values *@
3738
@Text.First(nameFromDb, nameFromProfile, defaultNameForThisCountry, "unknown")
38-
```
3939
40-
_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:_
41-
42-
```razor
4340
@* remove html from a wysiwyg-string *@
4441
@Tags.Strip(formattedText)
4542

0 commit comments

Comments
 (0)