1.0.44 • Published 1 year ago

config-template-merger v1.0.44

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

https://www.flaticon.com/free-icon/merge_690328 config-template-merger

Utility for merging json configs through various JSONs together, and by replacing variables.

CodeQL

pages-build-deployment

Setup

Directly in web page

Include the scripts in html as follow:

<script src="https://unpkg.com/config-template-merger/public/config-merger.js"></script>

Through NPM

Add to package.json:

  "dependencies": {
  	...
    "config-template-merger": "^1.0.0",
    ...
  }

Use Browserify to make classes available in browser

In package.json:

  "scripts": {
  	...
    "browserify": "browserify browserify/main.js -s dok-lib -o public/gen/compact.js",
    ...
  },

In browserify/main.js:

const { ConfigMerger } = require('config-template-merger');

module.exports = {
  ConfigMerger,
};

Components

ConfigMerger

Description

ConfigMerger is used to compose templates using various

Usage

path/test-template.json

{ "field2" : 345 }
  	const configMerger = new ConfigMerger(fileUtils, {
  		constant: 567,
  	});

  	const source = {
  		"field1": 123,
  		template: "test-template.json",
  		"field3": "{constant * 10}",
  		"multiField": {
  			"repeat": 5,
  			"value": "{index * 2}"
  		},
  	};

  	const result = await configMerger.process(source, "path/", {
  		viewportSize: [100, 200],
  	});


  	/* RESULT
{
  field2: 345,
  field1: 123,
  field3: 5670,
  multiField: [
    { value: 0 },
    { value: 2 },
    { value: 4 },
    { value: 6 },
    { value: 8 }
  ]
}
  	*/
 

Demo

demo

1.0.44

1 year ago

1.0.39

1 year ago

1.0.38

1 year ago

1.0.40

1 year ago

1.0.43

1 year ago

1.0.42

1 year ago

1.0.41

1 year ago

1.0.34

1 year ago

1.0.22

2 years ago

1.0.21

2 years ago

1.0.20

2 years ago

1.0.26

2 years ago

1.0.25

2 years ago

1.0.24

2 years ago

1.0.23

2 years ago

1.0.33

2 years ago

1.0.32

2 years ago

1.0.31

2 years ago

1.0.19

2 years ago

1.0.18

2 years ago

1.0.17

2 years ago

1.0.16

2 years ago

1.0.15

2 years ago

1.0.14

2 years ago

1.0.13

2 years ago

1.0.12

2 years ago

1.0.11

2 years ago

1.0.10

2 years ago

1.0.9

2 years ago

1.0.8

2 years ago

1.0.7

2 years ago

1.0.6

2 years ago

1.0.5

2 years ago

1.0.4

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago