mirror of
https://github.com/wiremock/WireMock.Net.git
synced 2026-03-23 09:30:59 +01:00
38 lines
1.2 KiB
C#
38 lines
1.2 KiB
C#
using System;
|
|
using HandlebarsDotNet;
|
|
using WireMock.Handlers;
|
|
|
|
namespace WireMock.Transformers
|
|
{
|
|
internal class HandlebarsContextFactory : IHandlebarsContextFactory
|
|
{
|
|
private static readonly HandlebarsConfiguration HandlebarsConfiguration = new HandlebarsConfiguration
|
|
{
|
|
UnresolvedBindingFormatter = "{0}"
|
|
};
|
|
|
|
private readonly IFileSystemHandler _fileSystemHandler;
|
|
private readonly Action<IHandlebars, IFileSystemHandler> _action;
|
|
|
|
public HandlebarsContextFactory(IFileSystemHandler fileSystemHandler, Action<IHandlebars, IFileSystemHandler> action)
|
|
{
|
|
_fileSystemHandler = fileSystemHandler;
|
|
_action = action;
|
|
}
|
|
|
|
public IHandlebarsContext Create()
|
|
{
|
|
var handlebars = Handlebars.Create(HandlebarsConfiguration);
|
|
|
|
WireMockHandlebarsHelpers.Register(handlebars, _fileSystemHandler);
|
|
|
|
_action?.Invoke(handlebars, _fileSystemHandler);
|
|
|
|
return new HandlebarsContext
|
|
{
|
|
Handlebars = handlebars,
|
|
FileSystemHandler = _fileSystemHandler
|
|
};
|
|
}
|
|
}
|
|
} |