|
1 | 1 | using System;
|
2 |
| -using System.Collections.Generic; |
3 | 2 | using System.IO;
|
4 |
| -using System.Linq; |
5 | 3 | using System.Text;
|
6 |
| -using System.Threading.Tasks; |
7 |
| -using System.Windows.Forms; |
8 | 4 | using HandlebarsDotNet;
|
9 | 5 |
|
10 | 6 | namespace Virtual_Data_Warehouse
|
@@ -182,6 +178,39 @@ public static void RegisterHandleBarsHelpers()
|
182 | 178 | }
|
183 | 179 |
|
184 | 180 | });
|
| 181 | + |
| 182 | + // Character spacing not satisfactory? Do not panic, help is near! Make sure the character spacing is righteous using this Handlebars helper. |
| 183 | + // Usage {{space sourceDataObject.name}} will space out (!?) the name of the source to 30 characters and a few tabs for lots of white spaces. |
| 184 | + Handlebars.RegisterHelper("space", (writer, context, args) => |
| 185 | + { |
| 186 | + string outputString = args[0].ToString(); |
| 187 | + if (outputString.Length < 30) |
| 188 | + { |
| 189 | + outputString = outputString.PadRight(30); |
| 190 | + } |
| 191 | + writer.WriteSafeString(outputString + "\t\t\t\t"); |
| 192 | + |
| 193 | + }); |
| 194 | + |
| 195 | + |
| 196 | + Handlebars.RegisterHelper("StringReplace", (writer, context, args) => |
| 197 | + { |
| 198 | + if (args.Length < 3) throw new HandlebarsException("The {{StringReplace}} function requires at least three arguments."); |
| 199 | + |
| 200 | + string expression = args[0] as string; |
| 201 | + |
| 202 | + if (args[0] is Newtonsoft.Json.Linq.JValue) |
| 203 | + { |
| 204 | + expression = ((Newtonsoft.Json.Linq.JValue)args[0]).Value.ToString(); |
| 205 | + } |
| 206 | + |
| 207 | + string pattern = args[1] as string; |
| 208 | + string replacement = args[2] as string; |
| 209 | + |
| 210 | + expression = expression.Replace(pattern, replacement); |
| 211 | + writer.WriteSafeString(expression); |
| 212 | + |
| 213 | + }); |
185 | 214 | }
|
186 | 215 | }
|
187 | 216 | }
|
0 commit comments