lucuma
1
I can’t get the each block to work. I have a simple setup but neither work. I am just trying to loop over a list.
var list = new List<Test>();
list.Add(new Test() { Id=1, Name="test"});
var context = new TemplateContext();
Dictionary<string,object> args = new Dictionary<string, object>();
args.Add("test", list);
context.Init();
var output = context.EvaluateTemplate(@"{#ul {each:test, id:'menu', class:'nav'} }} <li>{{it.Id}}</li> {{/ul}}", args);
output = context.EvaluateTemplate("{{#each test}} {{it.Id}} {{/each}}", args);
output.PrintDump();
mythz
2
I’m assuming you’re using the latest v5.1.1 on MyGet which has the new support for blocks right?
This is missing a {
it should start with {{#ul
.
var output = context.EvaluateTemplate(@"{#ul {each:test, id:'menu', class:'nav'} }} <li>{{it.Id}}</li> {{/ul}}", args);
This does work:
output = context.EvaluateTemplate("{{#each test}} {{it.Id}} {{/each}}", args);
And so does not using the prefix:
output = context.EvaluateTemplate("{{#each test}} {{Id}} {{/each}}", args);
lucuma
3
I am on 5.1.0 so I guess we need to upgrade.
mythz
4
I should be releasing v5.2 within the next hour or 2 so can just wait for the next release on NuGet.