2012-02-13 41 views
2

我有模板和兩個片段。我可以在模板中選擇動態代碼段嗎?LiftWeb Loc.Template參數

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 

回答

2

您應該使用ValueTemplate來代替它提供的當前解析值爲參數。下面

代碼是未經測試,但你應該得到的想法:

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