classafSlim::SlimTag

sys::Obj
  afSlim::SlimTag

A utility class for use by custom Slim components. Builds and writes a HTML tag with custom attrs.

addAttr

Source

This addAttr(Str name, Str? value := null)

Adds a attr name value pair. value may be null for boolean attributes.

addClass

Source

This addClass(Str? klass)

Adds a CSS class (if it's not null or empty).

addStyle

Source

This addStyle(Str name, Str? value, Str size := "")

Adds a single CSS property to the style attribute. size is appended to the value (if given). null values are skipped. value is wrapped in var(...) if a CSS var name (starts with --).

addStyle("padding", "2rem")
addStyle("margin", "padding", "sm")
addStyle("margin", "--padding-sm")
attrBool

Source

Bool attrBool(Str name)

Returns true if the attr name exists.

attrEnum

Source

Str? attrEnum(Str enum)

Returns the first enum value in the given SSV string, or null if not found.

attrInt

Source

Int? attrInt(Str name)

Returns the attr value as an Int.

attrSize

Source

Str? attrSize(Str name)

Returns the attr value as a standard size, an empty string if the base value, or null if not found.

attrStr

Source

Str? attrStr(Str name)

Returns the attr value.

attrs

Source

Str:Str? attrs

classes

Source

Str[] classes

fromCtx

Source

new fromCtx(SlimComponentCtx ctx, Str? tagName := null)

Creates a tag builder initialised from the given SlimComponentCtx.

Tag Name defaults to ctx, falls back to the given name, or defaults to div.

id

Source

Str? id

isSize

Source

Bool isSize(Str val)

Is the value one of the standard sizes?

make

Source

new make(Str? tagName := null)

Creates a tag builder.

Tag Name defaults to div.

sizes

Source

const static Str[] sizes := "xs sm lg xl".split

The standard sizes.

style

Source

Str style

tagName

Source

Str tagName

write

Source

This write(StrBuf out)

Writes the opening start tag to the given out.

writeEnd

Source

This writeEnd(StrBuf out)

Writes the end tag.