DotLiquid没有解析我的模板

时间:2013-11-15 21:58:51

标签: c# dotliquid

或者更好......有些事我做得不对:s

无论如何,这很简单,我有这个班级

[LiquidType("RegionName", "AreaName", "PropertyName", "PropertyAddress", "PropertyZipCode", "PropertyId", "YearBuilt", "CommunitySpecial", "PropertyPhone", "PetPolicy", "Ammenities", "Features", "ComissionRate", "Bedrooms", "Price", "Size", "Bathrooms", "Images", "Floorplan")]
public class AdModel:Ad
{
    public String BaseFolder;
    protected String PropertyId { get; set; }
    protected String RegionName { get; set; }
    protected string CommunitySpecial { get; set; }
    protected string PetPolicy { get; set; }
    protected string Ammenities { get; set; }
    protected string Features { get; set; }
    protected string ComissionRate { get; set; }
    protected String[] Images { get; set; }
    protected String Floorplan { get; set; }
    protected Byte[] FloorplanImage { get; set; }
    protected Byte[][] PropertyImages { get; set; }

    [...]

    private String ParseTemplate(String templateFilePath)
    {
        var tpl = Template.Parse(File.ReadAllText(templateFilePath));
        return tpl.Render(Hash.FromAnonymousObject(this));
    }

    [...]

}

我有这个模板:

{{Bedrooms}}Br in {{AreaName}} for only {{Price}}.

当我致电ParseTemplate(somePath);时,我得到的结果是:Br in for only

我做错了什么?

注意未在AdModel中声明并在此处提及的属性在广告中声明为公开,因此(理论上)从AdModel中访问它们应该没有问题

1 个答案:

答案 0 :(得分:1)

我在某处阅读(我认为它就是这样),dotLiquid'Rubizes'变量名称,所以一个疯狂的猜测将{{Bedrooms}}变成了{{bedrooms}}

去图