object currentAttr extends AttrHelper[Box]
Used to get an attribute by its name from the current snippet element. There are several means to getting attributes:
// Get a Box for the attribute:
val myAttr = S.currentAttr("test") openOr "Not found"
// Get an attribute or return a default value:
val myAttr = S.currentAttr("name", "Fred")
// Apply a transform function on the attribute value, or return an Empty:
val pageSize = S.currentAttr("count", _.toInt) openOr 20
// There are also prefixed versions:
val prefixedAttr = S.currentAttr("prefix", "name") openOr "Not found"
Note that this uses the data held in S.currentAttrs, which means that it will only find attributes from the current snippet element. For example, given the snippets:
<lift:MyStuff.snippetA foo="bar"> <lift.MyStuff.snippetB>...</lift.MyStuff.snippetB> </lift:MyStuff.snippetA>
Calling S.currentAttr("foo") from snippetB will return
Empty.
- Alphabetic
- By Inheritance
- currentAttr
- AttrHelper
- AnyRef
- Any
- Hide All
- Show All
- Public
- Protected
Type Members
- type Info = String
- Definition Classes
- currentAttr → AttrHelper
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
- Definition Classes
- AttrHelper
- def apply[T](key: String, f: (Info) => T, default: => T): T
- Definition Classes
- AttrHelper
- def apply[T](prefix: String, key: String, f: (Info) => T): Box[T]
- Definition Classes
- AttrHelper
- def apply[T](key: String, f: (Info) => T): Box[T]
- Definition Classes
- AttrHelper
- def apply(prefix: String, key: String, default: => Info): Info
- Definition Classes
- AttrHelper
- def apply(key: String, default: => Info): Info
- Definition Classes
- AttrHelper
- def apply(prefix: String, key: String): Box[Info]
- Definition Classes
- AttrHelper
- def apply(key: String): Box[Info]
- Definition Classes
- AttrHelper
- final def asInstanceOf[T0]: T0
- Definition Classes
- Any
- def clone(): AnyRef
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.CloneNotSupportedException]) @native()
- def convert[T](in: Option[T]): Box[T]
- Attributes
- protected
- Definition Classes
- currentAttr → AttrHelper
- 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])
- def findAttr(prefix: String, key: String): Option[Info]
- Attributes
- protected
- Definition Classes
- currentAttr → AttrHelper
- def findAttr(key: String): Option[Info]
- Attributes
- protected
- Definition Classes
- currentAttr → AttrHelper
- 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()
- def ~(prefix: String, key: String): Option[NodeSeq]
Returns the prefixed attribute value as an Option[NodeSeq] for easy addition to the attributes
- def ~(key: String): Option[NodeSeq]
Returns the unprefixed attribute value as an Option[NodeSeq] for easy addition to the attributes