/Handlebars.Net.Extension.Json

System.Text.Json extension for Handlebars.Net

Primary LanguageC#MIT LicenseMIT

Handlebars.Net.Extension.Json

CI Nuget performance


Quality Gate Status Reliability Rating Security Rating

Bugs Code Smells Coverage


GitHub issues questions GitHub issues help wanted


Purpose

Adds System.Text.Json.JsonDocument support to Handlebars.Net.

Install

dotnet add package Handlebars.Net.Extension.Json

Usage

var handlebars = Handlebars.Create();
handlebars.Configuration.UseJson();

Example

[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);
}

History