Handlebars Extension (#286)

* wip

* HandlebarsRegistrationCallback

* HandlebarsContextFactoryTests

* 1.0.21.0

* fix sonar

* LocalFileSystemHandler

* readme

* Fix System.IO.IOException
This commit is contained in:
Stef Heyenrath
2019-07-03 18:37:22 +02:00
committed by GitHub
parent 653e03fcd9
commit 93682c9bbf
37 changed files with 366 additions and 208 deletions

View File

@@ -0,0 +1,34 @@
using HandlebarsDotNet;
using System;
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 IHandlebars Create()
{
var handlebarsContext = Handlebars.Create(HandlebarsConfiguration);
HandlebarsHelpers.Register(handlebarsContext, _fileSystemHandler);
_action?.Invoke(handlebarsContext, _fileSystemHandler);
return handlebarsContext;
}
}
}