Scala LiftWeb Loc.Template参数

Scala LiftWeb Loc.Template参数,scala,lift,Scala,Lift,我有一个模板和两个代码段。我可以在选择动态代码段的模板中获取Id吗 def remote = Menu.param[Point]("Test1", "remote", id => inTransaction(Points.lookup(id)), _.id) / "point" / * / "remote" >> //inTransaction(Points.lookup(id)) match // case point.Kind.remote =>

我有一个模板和两个代码段。我可以在选择动态代码段的模板中获取Id吗

def remote =
  Menu.param[Point]("Test1", "remote",
  id => inTransaction(Points.lookup(id)), _.id) / "point" / * / "remote" >>
  //inTransaction(Points.lookup(id)) match
  //  case point.Kind.remote =>
  Loc.Template(() => Templates("point" :: "remote" :: Nil).openOr(Nil)) >> Hidden
  //  case point.Kind.otherremote =>
  //Loc.Template(() => Templates("point" :: "otherremote" :: Nil).openOr(Nil)) >> Hidden

您应该使用
ValueTemplate
,它提供了当前解析的值is参数

下面的代码未经测试,但您应该了解:

def remote = Menu.param[Point]("Test1", "remote",
  id => inTransaction(Points.lookup(id)), _.id) / "point" / * / "remote" >>
  Loc.ValueTemplate(point => point match
    case Full(p) if p.Kind.remote => Templates("point" :: "remote" :: Nil).openOr(Nil))
    case Full(p) if p.Kind.otherremote => Templates("point" :: "otherremote" :: Nil).openOr(Nil))
    case _ => NodeSeq.Empty
  ) >> Hidden