forked from sebastienros/fluid
-
Notifications
You must be signed in to change notification settings - Fork 0
/
DotLiquidBenchmarks.cs
54 lines (47 loc) · 1.41 KB
/
DotLiquidBenchmarks.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
using DotLiquid;
using System.Linq;
namespace Fluid.Benchmarks
{
public class DotLiquidBenchmarks : BaseBenchmarks
{
private readonly Template _dotLiquidTemplate;
public DotLiquidBenchmarks()
{
_dotLiquidTemplate = Template.Parse(ProductTemplate);
_dotLiquidTemplate.MakeThreadSafe();
}
private Hash MakeProducts()
{
return Hash.FromAnonymousObject(new
{
products = Products.Select(product => new Hash()
{
["name"] = product.Name,
["price"] = product.Price,
["description"] = product.Description
}).ToList()
});
}
public override object Parse()
{
var template = Template.Parse(ProductTemplate);
return template;
}
public override object ParseBig()
{
var template = Template.Parse(BlogPostTemplate);
return template;
}
public override string Render()
{
var products = MakeProducts();
return _dotLiquidTemplate.Render(products);
}
public override string ParseAndRender()
{
var template = Template.Parse(ProductTemplate);
var products = MakeProducts();
return template.Render(products);
}
}
}