JohT / JohT/data-restructor-js
"fieldName" and "value" in templateResolver could be configurable
- Dominant language
- JavaScript
- Stars
- 3
- Forks
- 0
- Avg merge
- 4h 25m
- Merged PRs (30d)
- 13
Description
**Actual behaviour**
[templateResolver.js](https://github.com/JohT/data-restructor-js/blob/master/src/js/templateResolver.js) is able to resolve variables with values, that are given by a two properties (a "fieldName" property and a "value" property). Here is an example:
```json
{ "fieldName": "street", "value": "Mainstreet" }
```
**Target behaviour**
It should be possible to configure the names of the properties, that contain the field name and value. Without configuration "fieldName" and "value" should remain the default. Changing the configuration to "propertyName" and "propertyValue" will resolve a structure like this:
```json
{ "propertyName": "street", "propertyValue": "Mainstreet" }
```
**Starting point**
There is already a [`TODO` comment mark](https://github.com/JohT/data-restructor-js/blob/c5868344cd6e106b0e4fa8254017cf6f98f36946/src/js/templateResolver.js#L117) inside the code that might be a good starting point.
It might make sense to introduce a "config" structure within "Resolver" that might look something like:
```javaScript
function Resolver(sourceDataObject) {
/**
* The properties of this source data object will be used to replace the placeholders in the template.
*/
this.sourceDataObject = sourceDataObject;
/**
* Contains additional configuration
*/
this.config = {fieldNameProperty: "fieldName, fieldNameValue: "value"};
...
```
Contributor guide
Assessment
This issue has not been assessed yet.