2013-11-15 46 views
1

或者更好的......有些事情我沒有做正確的:■DotLiquid不解析我的模板

無論如何,這是簡單的,我有這個類

[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

我看是accesing他們一個問題某處(我認爲它在這裏),dotLiquid'Rubizes'變量名稱,所以一個瘋狂的猜測將{{Bedrooms}}轉換爲{{bedrooms}}

去圖

+0

這是正確的 - DotLiquid處理使用命名約定對象。您可以使用'Template.NamingConvention = new * NamingConvention()'來更改命名約定。有兩個內置的:'CSharpNamingConvention'和'RubyNamingConvention'。正如你所發現的那樣,默認是'RubyNamingConvention'。 –