mirror of
https://github.com/wiremock/WireMock.Net.git
synced 2026-11-27 10:52:56 +01:00
- Add WireMockServerSettings.ScribanRegistrationCallback (Action<object, IFileSystemHandler>?) so code-configured servers can add functions, objects or variables to Scriban and Scriban-DotLiquid templates. - Pass the settings to ScribanContextFactory, which invokes the callback with a new ScriptObject per transformer context. - Push the custom globals beneath the template model in ScribanContext so request, response, mapping and data take precedence; keep the original Template.Render call when no callback is configured. - Add the strongly typed WithScribanRegistration extension method. - Add a Scriban example to the .NET 8 console app. - Make the proxy tests use a local target server instead of www.google.com, and skip the IPv6 loopback test when the OS has no IPv6 support. Co-authored-by: Mattias <13809209+Quattordici@users.noreply.github.com>
29 lines
1004 B
C#
29 lines
1004 B
C#
// Copyright © WireMock.Net
|
|
|
|
using WireMock.Settings;
|
|
using WireMock.Transformers.Handlebars;
|
|
using WireMock.Transformers.Scriban;
|
|
using WireMock.Types;
|
|
|
|
namespace WireMock.Transformers;
|
|
|
|
internal static class TransformerFactory
|
|
{
|
|
internal static ITransformer Create(TransformerType transformerType, WireMockServerSettings settings)
|
|
{
|
|
switch (transformerType)
|
|
{
|
|
case TransformerType.Handlebars:
|
|
var factoryHandlebars = new HandlebarsContextFactory(settings);
|
|
return new Transformer(settings, factoryHandlebars);
|
|
|
|
case TransformerType.Scriban:
|
|
case TransformerType.ScribanDotLiquid:
|
|
var factoryScriban = new ScribanContextFactory(settings, transformerType);
|
|
return new Transformer(settings, factoryScriban);
|
|
|
|
default:
|
|
throw new NotSupportedException($"{nameof(TransformerType)} '{transformerType}' is not supported.");
|
|
}
|
|
}
|
|
} |