npm.io
1.0.46 • Published 2 years ago

@presenta/config-interpolator

Licence
BSD-3-Clause
Version
1.0.46
Deps
1
Size
93 kB
Vulns
0
Weekly
0

Presenta Config Interpolator

This function accepts a data config and a template config and return a merged version useful to create a PRESENTA Lib document.

Usage

import { interpolate } from '@presenta/config-interpolator

const data = {
	myText: 'Hello',
	myText[color]: 'red', //
	myText[coords][top]: 20, //
	myText[hidden][hidden]: true
}

const templateConfig = {
	scenes:[{
		blocks:[{
			type: 'text',
			ukey: 'myText',
			content: ''
		}]
	}]
}

const config = await interpolate(data, templateConfig)

/*
const data = {
	myText: 'Hello'
}

const templateConfig = {
	scenes:[{
		blocks:[{
			type: 'text',
			ukey: 'myText',
			content: 'Hello'
		}]
	}]
}

*/