Options
All
  • Public
  • Public/Protected
  • All
Menu

Class NestableElement

The NestableElement class represents elements that have an opening and closing tag.

Hierarchy

Constructors

constructor

  • Constructs an nested element.

    Parameters

    • tag: string

      tag name of the element

    • Optional tier1: string | Renderable | Attributes

      The first level of parameters. If this parameter is a string, but it is not an identifier string, then it will be treated a string child and nothing should follow it. If this parameter is a string, and is an identifier string, then it will set the id and classes of the element. If this parameter is an Element, then it will become a child and every following parameter will need to be an Element as well. If this parameter is an Attributes, then it will set the attributes of the element and will need to be followed by either a string (as a child), an Element, or nothing.

    • Optional tier2: string | Renderable | Attributes

      The second level of parameters. If this parameter is a string then it will be treated a string child and nothing should follow it. If this parameter is an Element, then it will become a child and every following parameter will need to be an Element as well. If this parameter is an Attributes, then it will set the attributes of the element and will need to be followed by a set of Elements or none.

    • Rest ...children: (string | Renderable)[]

      A set of children elements.

    Returns NestableElement

Properties

Protected templates

templates: SimpleObject

Accessors

r

  • get r(): string
  • Getting for the HTML returned by the render function.

    Returns string

Methods

addChild

  • Appends a child.

    Parameters

    • child: Renderable | string

      either a string or renderable

    Returns Renderable

append

  • Appends templates to the existing templates object.

    Parameters

    • templates: SimpleObject

      Key-value pairs that map to a template rendered in StringLiteral's

    • Default value prioritize: boolean = false

      Whether or not to allow appended templates to override existing template properties

    Returns Renderable

getAttributes

getChildren

  • Gets the children.

    Returns Renderable[]

getClassList

  • getClassList(): Array<string>
  • Get element class list

    Returns Array<string>

Protected getHtmlAttributeList

  • getHtmlAttributeList(): string
  • Given an object of attributes, converts attributes into the HTML equivalent list.

    Returns string

getId

  • getId(): string | null
  • Get element id

    Returns string | null

getTag

  • getTag(): string
  • Get element tag

    Returns string

Protected internalRender

render

  • Renders the internalRender function.

    Parameters

    Returns string

setAttribute

  • Sets an attribute of the element

    Parameters

    • name: string

      Name of the attribute.

    • value: Attribute

      The attribute value. Alternatively accepts an array with the form: [condition, string1, string2?] which will use string1 if condition == trye. Otherwise it will use string2 if it exists. If string2 is not defined and condition == false, then the attribute will be omitted.

    Returns Element

setAttributes

setChildren

  • Sets the children.

    Parameters

    • Rest ...children: (string | Renderable)[]

      one or more children

    Returns Renderable

setClassList

  • setClassList(classes: Array<string>): Element
  • Sets the elements class list.

    Parameters

    • classes: Array<string>

      The new set of classes that the element will get.

    Returns Element

setId

  • Set the ID.

    Parameters

    • id: string

      The new id.

    Returns Element

Protected setIdentifierString

  • setIdentifierString(identifier: string): void
  • Set's the id and classes of the element given an identifier string.

    Parameters

    • identifier: string

      An identifier string. See isIdentifierString for more information.

    Returns void

setIdentifiers

  • setIdentifiers(identifier: string): Element
  • Set the identifiers.

    Parameters

    • identifier: string

      An identifier string. See isIdentifierString for more information.

    Returns Element

toString

  • toString(): string
  • Overrides the toString method called by JavaScript when string concatenate occurs

    Returns string

when

  • Turn on and off the ability for this element to render

    Parameters

    • condition: boolean

      The condition that determines whether or not the element can render.

    Returns Renderable

with

  • Sets the templates.

    Parameters

    • templates: SimpleObject

      Key-value pairs that map to a template rendered in StringLiteral's

    Returns Renderable

Static Protected isIdentifierString

  • isIdentifierString(tester: string): boolean
  • Determines if a string is an identifier string. An identifier string either starts with "#" or "." and specifies a list of identifiers for an element. An example is "#book.col.col-xs-5". There can only be a single id and it must be specified at the beginning. For example: ".col.col-xs-5#book" is not a valid identifier string.

    Parameters

    • tester: string

    Returns boolean

Generated using TypeDoc