2015-01-16 33 views
0

我使用StringTemplate 版本3StringTemplate C#elseif错误?

我有以下模板:

<html> 
    <head> 
    <title>Test</title> 
    <style> 
     .done-ok {   
      background-color : LawnGreen   
     } 
     .done-ignore {     
      background-color : Orange   
     } 
     .done-fail {     
      background-color : OrangeRed   
     }   
    </style> 
    </head> 
    <body class="$if(failedNonEmpty)$done-fail$elseif(needsAttentionNonEmpty)$done-ignore$else$done-ok$endif$"> 
    </body> 
</html> 

我使用下面的代码:

var stg = new StringTemplateGroup(templateName, new FileSystemTemplateLoader(Path.Combine(locationRoot, templateFolder))); 
    var st = stg.GetInstanceOf(templateName); 

    st.SetAttribute("passedNonEmpty", !true); 
    st.SetAttribute("failedNonEmpty", !true); 
    st.SetAttribute("needsAttentionNonEmpty", !true); 

    var content = st.ToString(); 

当我编译代码寄托都正常。奇怪的是,当我第二属性更改为:

st.SetAttribute("failedNonEmpty", true); 

然后,突然我得到的异常在说行st.ToString(): 模板没有文本“elseif的”

任何人有同样的问题或知道解决方案?

回答