对于Spark视图引擎/ ASP.NET MVC中的循环

时间:2012-12-30 10:31:59

标签: c# templates templating spark-view-engine

我正在使用Spark和WPF。这工作正常,我能够格式化模板并从自定义DTO(我的模型)中提取标量属性。虽然我很难找到循环工作。通过查看the Spark documentation,我应该可以做到这一点,但我得到一个火花异常:

Dynamic view compilation failed.

c:\Users\Echilon\AppData\Local\Temp\tmp4490.tmp(73,73): error CS0103: The name 'Sections' does not exist in the current context

以下代码在模板中正常工作以从模型中提取Name属性:<h1>${Name}</h1>但for循环生成异常:

<for each="var sect in Sections">
    ${#sect.Name}
    <!-- HTML for each element omitted -->
</for>

1 个答案:

答案 0 :(得分:0)

我需要导入collections命名空间以及包含IList中对象类型的命名空间:

<use namespace="System.Collections.Generic"/>
<use namespace="System.Web.Mvc"/>
<use namespace="MyOtherAssembly"/>
<viewdata Sections="IList[[ISection]]"/>
相关问题