1

或者更好……有些事情我做的不对: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 中声明且在此处提及的属性在 Ad 中被声明为 Public,因此(理论上)从 AdModel 中访问它们应该没有问题

4

1 回答 1

2

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

去搞清楚

于 2013-11-15T22:25:20.450 回答