JohT/data-restructor-js

"fieldName" and "value" in templateResolver could be configurable

Open

#14 opened on Jun 19, 2021

 (0 comments) (0 reactions) (0 assignees)JavaScript (0 forks)auto 404
good first issuepriority: could (3)

Repository metrics

Stars
 (3 stars)
PR merge metrics
 (PR metrics pending)

Description

Actual behaviour 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:

{ "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:

{ "propertyName": "street", "propertyValue": "Mainstreet" }

Starting point There is already a TODO comment mark 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:

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