Adds System.Text.Json.JsonDocument
support to Handlebars.Net.
dotnet add package Handlebars.Net.Extension.Json
var handlebars = Handlebars.Create();
handlebars.Configuration.UseJson();
[Fact]
public void JsonTestObjects()
{
var model = JsonDocument.Parse("{\"Key1\": \"Val1\", \"Key2\": \"Val2\"}");
var source = "{{#each this}}{{@key}}{{@value}}{{/each}}";
var handlebars = Handlebars.Create();
handlebars.Configuration.UseJson();
var template = handlebars.Compile(source);
var output = template(model);
Assert.Equal("Key1Val1Key2Val2", output);
}
- Inspired by rexm/Handlebars.Net/issues/304