【发布时间】:2011-08-02 08:36:39
【问题描述】:
尝试通过使用 Lift 框架开始使用 Scala,但我在创建我想象中的一个常见场景时遇到了麻烦:我有一个日期列表,并且每一天都有一个当天的项目列表(嵌套列表)。
我的想法是采用这种方法:
<div class="lift:DaySnippet">
<h1 class="day">Name of Day</h1>
<ul class="day-items">
<!-- wanted to have a separate snippet but haven't made it work -->
<!-- <li class="lift:DayItemSnippet">Item content</li> -->
<li class="item">
<span class="name">Name</span>
<span class="desc">Description</span>
</li>
</ul>
</div>
本来我并不打算拥有内在的 sn-p,但认为这是有道理的。
所以我可以像这样定义一个 sn-p:
class DaySnippet {
// Ignoring that this is a stupid way to define the data
val days = ("Monday", ("Item 1", "Item 1 Description") :: Nil) ::
("Tuesday", ("Item 2", "Item 2 Description") ::
("Item 3", "Item 3 Description") :: Nil) :: Nil;
def render = {
// EDIT: Original code was broken, this is what I was trying to show
"* *" #> days.map { case (day, items) => ".day *" #> day }
}
}
无论如何,我正在寻找一些关于嵌套 sn-ps 和/或如何迭代嵌套集合并使用 CssSels 修改整个 NodeSeq 的文档或示例。
我很乐意添加任何可能澄清的其他信息。
【问题讨论】: