I have been wanting to use the great DotLiquid and tried to following example (written by myself) without any major success.
internal class AuthorDrop : Drop {
private String lname;
public String ToGive { get { return lname; } }
public AuthorDrop(String t) {
lname = t;
}
}
with the corresponding test
[Test]
public void TestFirstStep() {
Template tpl = Template开发者_开发知识库.Parse("hi {{ author2.togive }}");
Console.WriteLine(tpl.Render(Hash.FromAnonymousObject(new { author2 = new AuthorDrop("Test 123") })));
}
However, this leades to the output
hi
instead of hi Test 123.
Can anyone help me figure out what's going on here?
Thank you so much in advance,
-- Chris
By default DotLiquid uses Ruby's naming convention for methods and properties. In your example ToGive is "renamed" as to_give.
If you prefer you can instead use C# naming convention by setting the static propery DotLiquid.Template.NamingConvention = new DotLiquid.NamingConventions.CSharpNamingConvention();
HTH
精彩评论