HtmlTemplate(template, opts) → {HtmlTemplate}

HTML templates for visualizations in Jupyter

new HtmlTemplate(template, opts) → {HtmlTemplate}

Create a HTML template from a file or string that can be rendered to HTML later using toHtml

Parameters:
Name Type Description
template string

The name of a file to load or a string representing a template

opts Object

Options for the template

Returns:
HtmlTemplate -

The newly created template

Methods

static getGlobals() → {object}

Return previously set global values. Mostly used for testing.

Returns:
object -

Object containing all set globals.

async, static init() → {Promise}

Initialize the templating system

Returns:
Promise -

A Promise that resolves with initialization is complete

static resetGlobals()

Remove all previously set global values. Mostly used for testing.

static setGlobal(key, val)

Set a global data value that will be passed as part of the data object in all templates as templateGlobal.

Parameters:
Name Type Description
key string

The property to set in templateGlobal

val any

The value to assign to the key

async, static shutdown() → {Promise}

Shutdown the templating system

Returns:
Promise -

A Promise that resolves when initialization is complete

toHtml(userData) → {string}

Convert data to HTML using the template

Parameters:
Name Type Description
userData Object

An object containing the data to be used in the template

Returns:
string -

The HTML of the rendered template