# Bootstrapping

## Introduction

To boot an EJS application, you must first include the pre-compiled bootstrap script. The bootstrap script is responsible for providing file loading, parsing, and dependency management.

The bootstrap script is located at:\
`ElentraJS/elentrajs.js`

## How It Works <a href="#how-it-works" id="how-it-works"></a>

The bootstrap script is simply a collection of classes from the EJS library included in a bundle.

## The Bootstrap Class <a href="#the-bootstrap-class" id="the-bootstrap-class"></a>

### Synopsis <a href="#synopsis" id="synopsis"></a>

```javascript
class Bootstrap {
    constructor(string srcPath);
    boot(string selector) : Promise<App>
}
```

### Methods <a href="#methods" id="methods"></a>

#### `constructor(string srcPath)` <a href="#constructorstring-srcpath" id="constructorstring-srcpath"></a>

Initializes a Bootstrap object. The srcPath argument specifies a directory path to be used when resolving dependencies.

#### `boot(string selector) : Promise<App>` <a href="#bootstring-selector-promiseapp" id="bootstring-selector-promiseapp"></a>

Loads the initial App class, its dependencies, and its configuration (`environment.js`) and returns a Promise. If the Promise resolves, it will return the application instance.

### Examples <a href="#examples" id="examples"></a>

#### Example 1: Booting an EJS application <a href="#example-1-booting-an-elentrajs-application" id="example-1-booting-an-elentrajs-application"></a>

```markup
<script src="path/to/ElentraJS/elentrajs.js">
<script>
    let bootstrap = new Bootstrap('path/to/src');

    bootstrap.boot('#app-root').then(app => {
        ...
    });
</script>
```
