Skip to content
Snippets Groups Projects
Helpers-functions.rst 3.35 KiB

Javascript Helpers

Helpers fonctions

Those function are inclued in the core.

Function Parameters Description
uniqID   create an uniq ID, used for example to associate input with label
stringToDom html parse html string and return DOM fragment
evalTemplateString str, variables = {} eval a string as an es6 template string. example: evalTemplateString('name: ${first} ${last}', {first: 'John', last: 'Doe'})
importCSS [...stylesheets] add style in document if not present
importJS [...script] add script in document if not present

If you’re writing a component

Creating a component, you should import those function like this :

import { Helpers } from "https://unpkg.com/@startinblox/core@0.10";

You should always use importCSS and importJS to make your extra importation. Otherwise, you’ll get this king of message :

Le chargement du module à l’adresse « https://the/road/to/your/extra/script » a été bloqué en raison d’un type MIME interdit (« text/html »).

Store function

Our goal is to avoid manipulating javascript to use our tools. But it can happen that depending on the case you need some small manipulation and these functions can help you.

Each time you need to use javascript for your development, please give us feedback so that we can take into account your problems in the next versions of the framework. Thanks for!