Skip to content

Latest commit

 

History

History
53 lines (34 loc) · 3.17 KB

File metadata and controls

53 lines (34 loc) · 3.17 KB

Handlebars.Net.Extension.NewtonsoftJson

CI Nuget performance


Quality Gate Status Reliability Rating Security Rating

Bugs Code Smells Coverage


GitHub issues questions GitHub issues help wanted


Purpose

Adds proper Newtonsoft.Json support to Handlebars.Net

Install

dotnet add package Handlebars.Net.Extension.NewtonsoftJson

Usage

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

Example

[Fact]
public void JsonTestObjects()
{
    var model = JObject.Parse("{\"Key1\": \"Val1\", \"Key2\": \"Val2\"}");

    var source = "{{#each this}}{{@key}}{{@value}}{{/each}}";

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

    var template = handlebars.Compile(source);

    var output = template(model);

    Assert.Equal("Key1Val1Key2Val2", output);
}