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
+46
Original file line number
Diff line number
Diff line change
@@ -73,6 +73,52 @@ Slug generated from "Test | 🤡" with custom map: "test_or_clown"
73
73
74
74
```
75
75
76
+
## Slug Custom Computation Expression
77
+
78
+
It is possible to use the custom Computation Expression in order to define your custom slugify function.
79
+
80
+
Here a simple example:
81
+
82
+
```fsharp
83
+
open FSlugify.Builder
84
+
85
+
[<EntryPoint>]
86
+
let main argv =
87
+
printfn "This example shows how to use the custom Slug Computation Expression!\n"
88
+
89
+
let customSlugify = slug {
90
+
separator '@'
91
+
lowercase false
92
+
custom_map ("|", " or ")
93
+
custom_map ("&", " and ")
94
+
custom_map ("⏳", " hourglass ")
95
+
custom_map ("🤡", " clown")
96
+
}
97
+
98
+
customSlugify "Test | Case"
99
+
|> printfn "Slug generated from \"Test | Case\": \"%s\"\n"
100
+
101
+
customSlugify " Test & ⏳ "
102
+
|> printfn "Slug generated from \" Test & ⏳ \": \"%s\"\n"
103
+
104
+
customSlugify "HI 🤡!!!"
105
+
|> printfn "Slug generated from \"HI 🤡!!!\": \"%s\"\n"
106
+
0
107
+
108
+
```
109
+
This program will output the following text:
110
+
111
+
```shell
112
+
This example shows how to use the custom Slug Computation Expression!
113
+
114
+
Slug generated from "Test | Case": "Test@or@Case"
115
+
116
+
Slug generated from " Test & ⏳ ": "Test@and@hourglass"
117
+
118
+
Slug generated from "HI 🤡!!!": "HI@clown"
119
+
120
+
```
121
+
76
122
## FSlugify.Adapter
77
123
78
124
Although the library is usable as it is in a C# project (as it shown in the C# sample), for a better usability (both in syntax and usability) it's preferred to use the library [FSlugify.Adapter](https://github.com/galassie/fslugify-adapter).
0 commit comments