JSOI

jsoi-lib

Here you can find the distribution (build) files for jsoi. JSOI is designed specifically for templating javascript objects.
It is designed to aid in building dynamic and conditional configuration objects while preserving types in output if possible.

REPO

The JSOI repo can be found here: JSOI Repo; along with documentation and example use cases.

JSOI Distribution

There are multiple ways to get JSOI build files. You can either grab the prebuilt files or install it via npm. Prebuilt distribution files come in both minimized (*.min.js) and non-minimized (*.js) versions, with support for ES Modules, CommonJS (Node.js), and global scope (browser-side). Below are examples for importing and simple use. However, see the main repo for full documentation JSOI Repo

icon

Installation

Installation npm

  npm update jsoi-lib

Installation npm latest build

  npm install https://code4ward.github.io/JSOI/jsoi-lib-latest.tgz

Installation download

latest tarball

Script tag unpkg.com

<script src="https://unpkg.com/jsoi-lib@latest/interpolation_objects.gs.min.js"></script>

Script tag GIT hosting

<script src="https://code4ward.github.io/JSOI/interpolation_objects.gs.js"></script>

For Module Import

For ES Module usage, include one of the following files in your project, depending on your preference for minimized or non-minimized builds. These are ideal for modern environments that support import/export.

Minimized

Non-Minimized

Using as module import in node

Example below shows node import. Note package.json should have "type": "module".

import { ObjectInterpolator } from "jsoi-lib";

( async () => {

    const obj = {
        A: `{{ One }}`
    };

    const oi = new ObjectInterpolator(obj, {
        One: 1
    }, {});
    await oi.interpolate();
    console.log(obj);
    
})();

Output:

{
  "A": 1,
}

For CommonJS for Node.js

For ES Module usage, include one of the following files in your project, depending on your preference for minimized or non-minimized builds. These are ideal for modern environments that support import/export.

Minimized

Non-Minimized

Using as require in node

Example below shows node import.

const { ObjectInterpolator } = require("jsoi-lib");

(async () => {
    const obj = {
        A: `{{ One }}`
    };

    const oi = new ObjectInterpolator(obj, {
        One: 1
    }, {});
    await oi.interpolate();
    console.log(obj);
})();

For Browser global scope

For browser namespace JSOI should be used.

Minimized

Non-Minimized

Using as require in node

Example below shows browser load with script tag. The example is also online: jsoi_example_gs

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Global Scope Example</title>
</head>
<body>
  <h1>JSOI Global Scope Example (Open Debug Console for result)</h1>
  <script src="interpolation_objects.gs.js"></script>

  <script>
    (async () => {
        const obj = {
            A: `{{ One }}`
        };

        // Use the global `ObjectInterpolator` from the included script
        const oi = new JSOI.ObjectInterpolator(obj, {
            One: 1
        }, {});
        await oi.interpolate();
        console.log(obj);
    })();
  </script>
</body>
</html>

Note: In django you will need to wrap the code above in verbatim, required so tags are not confused


{% verbatim %}
...
{% endverbatim %}