src/main/scala/net/tz/lift/snippet/Panel.scala
changeset 21 641c7190c566
parent 15 995184977e9b
child 22 94ed9cfdb123
equal deleted inserted replaced
20:f1551f9d3d3e 21:641c7190c566
     1 /*
     1 /*
     2  * Copyright 2011 Tomas Zeman <tzeman@volny.cz>
     2  * Copyright 2011-2012 Tomas Zeman <tzeman@volny.cz>
     3  *
     3  *
     4  * Licensed under the Apache License, Version 2.0 (the "License");
     4  * Licensed under the Apache License, Version 2.0 (the "License");
     5  * you may not use this file except in compliance with the License.
     5  * you may not use this file except in compliance with the License.
     6  * You may obtain a copy of the License at
     6  * You may obtain a copy of the License at
     7  *
     7  *
    51   def &(other: Function1[NodeSeq, NodeSeq]) = new Function1[NodeSeq, NodeSeq] {
    51   def &(other: Function1[NodeSeq, NodeSeq]) = new Function1[NodeSeq, NodeSeq] {
    52     def apply(in: NodeSeq): NodeSeq = List(Panel.this, other) flatMap (_(in))
    52     def apply(in: NodeSeq): NodeSeq = List(Panel.this, other) flatMap (_(in))
    53   }
    53   }
    54 }
    54 }
    55 
    55 
    56 import net.liftweb.http.TemplateFinder
    56 import net.liftweb.http.Templates
    57 import net.liftweb.util.Helpers._ // CSS transforms
    57 import net.liftweb.util.Helpers._ // CSS transforms
    58 
    58 
    59 /**
    59 /**
    60  * A panel using template in <code>/templates-hidden/panel</code> for
    60  * A panel using template in <code>/templates-hidden/panel</code> for
    61  * values rendering.
    61  * values rendering.
    62  */
    62  */
    63 class TplPanel(cells: List[(NodeSeq, NodeSeq)]) extends CssTr {
    63 class TplPanel(cells: List[(NodeSeq, NodeSeq)]) extends CssTr {
    64   def apply(in: NodeSeq): NodeSeq = TemplateFinder.findAnyTemplate(
    64   def apply(in: NodeSeq): NodeSeq = Templates(
    65     List("templates-hidden", "panel")) map { xml =>
    65     List("templates-hidden", "panel")) map { xml =>
    66     (".row *" #> cells.map { r =>
    66     (".row *" #> cells.map { r =>
    67       ".n *" #> r._1 &
    67       ".n *" #> r._1 &
    68       ".v *" #> r._2
    68       ".v *" #> r._2
    69     })(xml)
    69     })(xml)