CSharp · Console
public class Program
{
public static void Main()
{
var template = GetTemplate();
var json = GetJson();
System.Console.WriteLine(Environment.NewLine);
System.Console.WriteLine(json);
//var stubble = new Stubble.Core.Builders.StubbleBuilder().Build();
//var output = stubble.Render(template, json);
var output = Nustache.Core.Render.StringToString(template,json);
System.Console.Write(output);
}
private static string GetTemplate()
{
return @"<!DOCTYPE html>
<html lang=""en"">
<head>
<meta charset=""UTF-8"">
<title>Title</title>
</head>
<body>
<H3>
{{targetPatient.personName.firstName}} {{targetPatient.personName.lastName}}
</H3>
</body>
</html>
";
}
private static string GetJson()
{
return @"{
""targetPatient"": {
""address"": {
""city"": ""Moore"",
""country"": null,
""lines"": [
""123 Main Street""
],
""state"": ""SC"",
""zip"": ""29388""
},
""communicationList"": null,
""dateOfBirth"": ""1970-02-01"",
""gender"": ""M"",
""personName"": {
""firstName"": ""Johnny"",
""lastName"": ""Smith""
}
}
} ";
}
}