Skip to content

Commit 73fcf96

Browse files
Adding Util.tt for types models generation
1 parent cb25e28 commit 73fcf96

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

Templates/TypeScript/src/utils.tt

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
<#@ template debug="true" hostspecific="true" language="C#" #>
2+
<#@ output extension="\\" #>
3+
<#+
4+
class Utils {
5+
public static List<string> splitString(string str, int chunkSize) {
6+
// Removing non-breaking space in a string
7+
str = str.Replace("\u00A0", " ");
8+
List<string> multiLineDescription = new List<string>();
9+
if(str != null) {
10+
string[] words = str.Split(' ');
11+
string singleLineDescription = "";
12+
foreach(var word in words) {
13+
if(word == "") {
14+
continue;
15+
}
16+
var descriptionBeforeValuation = "";
17+
if(singleLineDescription == "") {
18+
descriptionBeforeValuation = word;
19+
} else {
20+
descriptionBeforeValuation = singleLineDescription + " " + word;
21+
}
22+
if(descriptionBeforeValuation.Length < chunkSize) {
23+
singleLineDescription = descriptionBeforeValuation;
24+
} else {
25+
multiLineDescription.Add(singleLineDescription);
26+
singleLineDescription = word;
27+
}
28+
}
29+
if(singleLineDescription != "") {
30+
multiLineDescription.Add(singleLineDescription);
31+
}
32+
}
33+
return multiLineDescription;
34+
}
35+
}
36+
#>

0 commit comments

Comments
 (0)