trait AttrHelper[+Holder[X]] extends AnyRef
A common function-like interface for accessing information about
attributes, based on the two core findAttr and
convert methods.
Extenders can be fairly flexible. The value of an attribute is
specified by the extender as type Info. Possibly-missing
attributes are returned in type Holder, which should be
parametrizable. For example, you could create an AttrHelper that
deals in String attribute values (type Info = String)
and returns Options in cases where the attribute may not
be found.
Note that you can invoke an AttrHelper with conversion
functions to turn an Info into an arbitrary type.
A sample implementation:
case class HtmlAttributes(in: Elem) extends AttrHelper[Box] { type Info = String def findAttr(key: String): Option[Info] = { in.attribute(key).map(_.text) } def findAttr(prefix: String, key: String): Option[Info] = { in.attribute(prefix, key).map(_.text) } def convert[T](in: Option[T]): Box[T] = Box(in) }
The helper above takes a scala Elem and provides a
series of ways to access the values of its elements. For example:
val attributes = HtmlAttributes(elem) attributes("class") // class attribute as String, Empty if absent attributes("lift", "bind") // as above with lift:bind attribute attributes("class", "nothing") // class attribute, "nothing" if absent attributes("lift", "bind", "nothing") // as above with lift:bind attribute attributes("class", _.split(" ")) // class attribute as array, Empty if absent attributes("lift", "bind", _.split(" ")) // as above with lift:bind attribute attributes("class", _.split(" "), Array()) // class attribute as array, Array() if absent attributes("lift", "bind", _.split(" "), Array()) // as above with lift:bind attribute
- Alphabetic
- By Inheritance
- AttrHelper
- AnyRef
- Any
- Hide All
- Show All
- Public
- Protected
Type Members
- abstract type Info
Abstract Value Members
Concrete Value Members
- final def !=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- final def ##: Int
- Definition Classes
- AnyRef → Any
- final def ==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- def apply[T](prefix: String, key: String, f: (Info) => T, default: => T): T
- def apply[T](key: String, f: (Info) => T, default: => T): T
- def apply[T](prefix: String, key: String, f: (Info) => T): Holder[T]
- def apply[T](key: String, f: (Info) => T): Holder[T]
- def apply(prefix: String, key: String, default: => Info): Info
- def apply(key: String, default: => Info): Info
- def apply(prefix: String, key: String): Holder[Info]
- def apply(key: String): Holder[Info]
- final def asInstanceOf[T0]: T0
- Definition Classes
- Any
- def clone(): AnyRef
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.CloneNotSupportedException]) @native()
- final def eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- def equals(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef → Any
- def finalize(): Unit
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.Throwable])
- final def getClass(): Class[_ <: AnyRef]
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
- def hashCode(): Int
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
- final def isInstanceOf[T0]: Boolean
- Definition Classes
- Any
- final def ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- final def notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
- final def notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
- final def synchronized[T0](arg0: => T0): T0
- Definition Classes
- AnyRef
- def toString(): String
- Definition Classes
- AnyRef → Any
- final def wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- final def wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- final def wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException]) @native()