1.0.44 • Published 2 years ago
config-template-merger v1.0.44
config-template-merger
Utility for merging json configs through various JSONs together, and by replacing variables.
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
1.0.44
2 years ago
1.0.39
3 years ago
1.0.38
3 years ago
1.0.40
3 years ago
1.0.43
2 years ago
1.0.42
3 years ago
1.0.41
3 years ago
1.0.34
3 years ago
1.0.22
3 years ago
1.0.21
3 years ago
1.0.20
3 years ago
1.0.26
3 years ago
1.0.25
3 years ago
1.0.24
3 years ago
1.0.23
3 years ago
1.0.33
3 years ago
1.0.32
3 years ago
1.0.31
3 years ago
1.0.19
3 years ago
1.0.18
3 years ago
1.0.17
3 years ago
1.0.16
3 years ago
1.0.15
3 years ago
1.0.14
3 years ago
1.0.13
3 years ago
1.0.12
3 years ago
1.0.11
3 years ago
1.0.10
3 years ago
1.0.9
3 years ago
1.0.8
3 years ago
1.0.7
3 years ago
1.0.6
3 years ago
1.0.5
3 years ago
1.0.4
3 years ago
1.0.3
3 years ago
1.0.2
3 years ago
1.0.1
3 years ago