Merge commit from fork

This commit is contained in:
Stef Heyenrath
2025-03-04 17:58:38 +01:00
committed by GitHub
parent be55022a2a
commit ff36c1ee6f
8 changed files with 86 additions and 20 deletions

View File

@@ -11,6 +11,8 @@ namespace WireMock.Transformers.Handlebars;
internal class FileHelpers : BaseHelpers, IHelpers
{
internal const string Name = "File";
private readonly IFileSystemHandler _fileSystemHandler;
public FileHelpers(IHandlebars context, IFileSystemHandler fileSystemHandler) : base(context)
@@ -18,12 +20,12 @@ internal class FileHelpers : BaseHelpers, IHelpers
_fileSystemHandler = Guard.NotNull(fileSystemHandler);
}
[HandlebarsWriter(WriterType.String, usage: HelperUsage.Both, passContext: true, name: "File")]
[HandlebarsWriter(WriterType.String, usage: HelperUsage.Both, passContext: true, name: Name)]
public string Read(Context context, string path)
{
var templateFunc = Context.Compile(path);
var transformed = templateFunc(context.Value);
return _fileSystemHandler.ReadResponseBodyAsString(transformed);
var transformedPath = templateFunc(context.Value);
return _fileSystemHandler.ReadResponseBodyAsString(transformedPath);
}
public Category Category => Category.Custom;