Class BaseLayout<T, K>Abstract

Type Parameters

Hierarchy

  • BaseLayout

Constructors

Properties

encodeFormType: "form-data" | "urlencoded" = 'urlencoded'

The type of encoding to use for the form, will be automatically set by the bodyParser middleware

error: string = ''

The error message that you get from internal errors, such as validation errors from connectClick

reflectFormData: false | ReflectFormDataOptions = ...

Reflect form data on post, meaning that the form will be filled with the data that was sent use data-reflect attribute to enable it on a specific element use data-reflect="false" to disable it on a specific element

path: string

The path of the page (express route) Can include params, for example: /user/:id

Methods

  • Connect a click event to a function

    Parameters

    • func: (() => any)

      the function to call

        • (): any
        • Returns any

    • __namedParameters: {
          catchErrors: undefined | boolean;
          name: undefined | string;
      } = {}
      • catchErrors: undefined | boolean
      • name: undefined | string

    Returns any

    Example

    // in useMiddleware
    this.connectClick(this.buttonClicked);

    // in render
    <button name="click" value="buttonClicked">show info</button>
  • Get a file from the request body

    Parameters

    • name: string
    • validate: ZodType<any, ZodTypeDef, any> = DEFAULT_FILE_VALIDATION

    Returns Promise<File>

  • Get a field from the request body

    Parameters

    • name: string
    • validate: ZodType<any, ZodTypeDef, any> = DEFAULT_FILED_VALIDATION

    Returns Promise<string>

  • Parameters

    • fullPath: string
    • parent: string = ...
    • options: HTMLScriptElement = ...

    Returns void

  • Parameters

    • fullPath: string
    • parent: string = ...
    • Optional options: HTMLLinkElement
      Optional

    Returns void

  • Called after the render is finished

    Returns Promise<void>

  • Called after all middlewares are registered

    Returns Promise<void>

  • Connect express middleware or use built in middleware

    super.useMiddleware register built in middleware, you can configure it by providing options

    Parameters

    Returns void