
com.homedepot.bigbricks.ui.HTMLCodeGenerator.scala Maven / Gradle / Ivy
The newest version!
package com.homedepot.bigbricks.ui
import net.liftweb.common.{Box, Empty, Full}
import scala.xml.{Attribute, Elem, NodeSeq, Null, Text}
/**
* Created by fjacob on 8/9/15.
*/
trait HTMLCodeGenerator {
val bsformFormElement: (NodeSeq, NodeSeq) => NodeSeq =
(name, form) =>
{form}
implicit def toTD(text: String): Elem = {
{text}
}
def createTable[T](t: List[T], transformations: (String, (T) => Elem)*) = {
val content = t.map(f => {
{transformations.map(g => {
g._2(f)
})}
})
createTableTemplateWithColumns(content, transformations.map(f => f._1): _*)
}
def createTableTemplateWithColumns(content: NodeSeq, columns: String*) = {
{columns.map(f =>
{f}
)}
{content}
}
def addClassAttribute(input: Any) = {
input match {
case Full(x: Elem) => {
Full({
x % Attribute(None, "class", Text("form-control"), Null)
})
}
case Full(x: NodeSeq) => {
Full(
{x.map(f => f.asInstanceOf[Elem] % Attribute(None, "class", Text("form-control"), Null))}
)
}
case _ => {
Empty
}
}
}
def addPasswordConfirm(input: Box[NodeSeq]) = {
input match {
case Full(node: NodeSeq) => {
val textBoxes = (node \ "input").map(f => f.asInstanceOf[Elem] % Attribute(None, "class", Text("form-control"), Null))
Full(
{textBoxes(0)}
{textBoxes(1)}
)
}
case _ => input
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy