Skip to content

Handlebars-Net/Handlebars.Net.Extension.Json

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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