Files
WireMock.Net-wiremock/src/WireMock.Net/Transformers/Handlebars/WireMockHandlebarsHelpers.cs
2021-02-09 20:35:44 +01:00

36 lines
1.1 KiB
C#

using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
using HandlebarsDotNet;
using HandlebarsDotNet.Helpers;
using HandlebarsDotNet.Helpers.Helpers;
using WireMock.Handlers;
namespace WireMock.Transformers.Handlebars
{
internal static class WireMockHandlebarsHelpers
{
public static void Register(IHandlebars handlebarsContext, IFileSystemHandler fileSystemHandler)
{
// Register https://github.com/StefH/Handlebars.Net.Helpers
HandlebarsHelpers.Register(handlebarsContext, o =>
{
o.CustomHelperPaths = new string[]
{
Directory.GetCurrentDirectory()
#if !NETSTANDARD1_3
, Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location)
#endif
}
.Distinct()
.ToList();
o.CustomHelpers = new Dictionary<string, IHelpers>
{
{ "File", new FileHelpers(handlebarsContext, fileSystemHandler) }
};
});
}
}
}