using RazorEngineCore;
var eng = new RazorEngine();
var content = @"Your favourite colors are:
@foreach(var color in Model.Colors) {
@color.Name
}
";
var templ = eng.Compile(content);
var model = new
{
Colors = new List<Color>()
{
new Color { Name = "Green" },
new Color { Name = "Red" }
}
};
var result = templ.Run(model);
Console.Write(result);
public struct Color
{
public string Name { get; set; }
}
Currently throws this exception:
System.InvalidCastException: 'Unable to cast object of type 'System.Collections.Generic.List`1[Color]' to type 'System.Collections.Generic.IEnumerable`1[System.Object]'.'
This code:
Currently throws this exception: