A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/Handlebars-Net/Handlebars.Net.Extension.Json below:

Handlebars-Net/Handlebars.Net.Extension.Json: System.Text.Json extension for Handlebars.Net

Handlebars.Net.Extension.Json

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

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4