Used to get an attribute by its name. There are several means to getting
attributes:
// Get a Box for the attribute:
val myAttr = S.attr("test") openOr "Not found"
// Get an attribute or return a default value:
val myAttr = S.attr("name", "Fred")
// Apply a transform function on the attribute value, or return an Empty:
val pageSize = S.attr("count", _.toInt) openOr 20
// There are also prefixed versions:
val prefixedAttr = S.attr("prefix", "name") openOr "Not found"
Note that this uses the data held in S.attrs, which means that
it will find attributes through the entire snippet nesting stack.
For example, given the snippets:
Used to get an attribute by its name. There are several means to getting attributes:
Note that this uses the data held in S.attrs, which means that it will find attributes through the entire snippet nesting stack. For example, given the snippets:
Calling
S.attr("foo")
from snippetB will returnFull("bar")
.