在我的模型中,我做了以下事情:
object ownerId extends StringRefField(this, User, 120)
并在代码中:
def render = {
".count *" #> posts.length &
".posts *" #> posts.map { p =>
".post *" #> Unparsed(p.body.get.replaceAll("\n", "<br>")) &
".time *" #> TimeHelpers.hourFormat(p.at.get) &
".user *" #> p.ownerId.obj.map ({ u =>
".username *" #> u.username.get &
".avatar *" #> Gravatar.imgTag(u.email.get, 64)
})
}
}
和模板:
<div class="lift:comet?type=PostActor">
<div class="count"></div>
<div class="posts">
<div class="media well">
<div class="user">
<a class="pull-left" href="#"> <span class="avatar"></span>
</a>
<div class="media-body">
<h4 class="media-heading"><span class="username"></span></h4>
</div>
</div>
<p><span class="post"></span></p>
<small><span class="time"></span></small>
</div>
</div>
生成的html是一组嵌套的帖子
<div class="posts">
<div class="media well">
<p>
hi
</p>
<small>23:39:10</small>
</div>
</div><div class="posts">
问题是用户详细信息没有显示,有人能告诉我我缺少什么吗?