Created
March 9, 2019 15:27
-
-
Save TechWatching/14bc3bba36aafefb364d4c89d7570c90 to your computer and use it in GitHub Desktop.
C# script that use the Handlebars.Net library to do HTML templating
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#r "nuget: Handlebars.Net, 1.9.5" | |
using HandlebarsDotNet; | |
string html = @" | |
<ul class=""people""> | |
{{#each people}} | |
<li>{{FirstName}} {{LastName}} - {{Job}}</li> | |
{{/each}} | |
</ul>"; | |
var data = new | |
{ | |
people = new [] | |
{ | |
new { FirstName = "Ellana", LastName = "Caldin", Job = "Marchombre"}, | |
new { FirstName = "Edwin", LastName = "Til'Illan", Job = "General"} | |
} | |
}; | |
var template = Handlebars.Compile(html); | |
string result = template(data); | |
Console.WriteLine(result); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment