using DotLiquid;using DotLiquid.NamingConventions;using System;using System.Collections.Generic;
public class User : Drop{ public string Name { get; set; } public List<Task> Tasks { get; set; }}
public class Task{ public string Name { get; set; }}namespace TestDotLiquidLoop{
class Program { static void Main(string[] args) { //Console.WriteLine("Hello World!"); //const string template1 = "{{ user.name | upcase }} has to do:{% for item in user.tasks -%}{ { item.name } }{% endfor -%}"; const string template = "<p>{{ user.name | upcase }} has to do:</p>" + "< ul >{% for item in user.tasks -%}" + "< li >{ { item.name } }</ li >" + "{% endfor -%}" + "</ ul > "; Template preparedTemplate = Template.Parse(template);
var user = new User { Name = "Tim Jones", Tasks = new List<Task> { new Task { Name = "Documentation" }, new Task { Name = "Code comments" } } }; Console.WriteLine(preparedTemplate.Render(DotLiquid.Hash.FromAnonymousObject(new { usertemp = user }))); } }}
I believe Task class has to inherit Drop as well.
With regards,
David.
--
You received this message because you are subscribed to the Google Groups "dotliquid" group.
To unsubscribe from this group and stop receiving emails from it, send an email to
dotliquid+...@googlegroups.com.
To view this discussion on the web visit
https://groups.google.com/d/msgid/dotliquid/fe82511f-28c2-4c0f-9759-31d32747d1b6o%40googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/dotliquid/MWHPR19MB0126500216B92C06721F2900999F0%40MWHPR19MB0126.namprd19.prod.outlook.com.
If you can share your working sample on GitHub it could be of help to the next engineer ramping up on DotLiquid.
Cheers,
To view this discussion on the web visit https://groups.google.com/d/msgid/dotliquid/CAG_8r8NQ9EG0yzb8yWThCdU9193DfEguC9h7g03y2DXZq2t%3DLA%40mail.gmail.com.