Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Switch<T>

The Switch class renders one out of one or more renderable based on the value of the switch. TODO: [p3] Nyc is reporting a missed branch here. Further investigation needs to be done to restore 100% coverage.

Type parameters

Hierarchy

Classes

Constructors

Properties

Accessors

Methods

Constructors

constructor

  • new Switch(value: T, ...cases: Case<T>[]): Switch
  • Constructor

    Parameters

    • value: T

      The value determines which cases is chosen and rendered.

    • Rest ...cases: Case<T>[]

      A set of cases with a value associated to it.

    Returns Switch

Properties

Protected templates

templates: SimpleObject

Accessors

r

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

    Returns string

Methods

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

default

  • Sets the default renderable when no case is found.

    Parameters

    • toRender: Renderable | string

      The default renderable if no case is found.

    Returns Switch<T>

Protected internalRender

render

  • Renders the internalRender function.

    Parameters

    Returns string

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

Generated using TypeDoc