Open suresh-gangumalla opened 2 months ago
@uguraslan
I have updated key specific regular expressions into a generic expression.
The generic regular expression is /\w+\s*:\s*(?:[^\s,}]+|".*?"|'.*?')/g
,
Sample input object with dynamic values and static value
"{x: $mX, y: 1}".match(regEx)
results to ['x: $mX', 'y: 1']
"{x: $mX, y: $mY}".match(regEx)
results to ['x: $mX', 'y: $mY']
"{top: '0xff0000ff', bottom: $colorB, left:$colorL, right: $colorR}"
results to["top: '0xff0000ff'", 'bottom: $colorB', 'left:$colorL', 'right: $colorR']
Resolved issue with dealing dyanmic arguments in an object that has assiged to attribute. This issue is mainly occurs with mount, pivot and color attribute when object litteral is assigned as value with dynamic arguments.
<Element color="{top: $colorT, bottom: $colorB, left:$colorL} mount="{x: $mX, y: $mY}">
Code generator now able to correctly link dynamic values for above code snippet. It will output,
elementConfig1['color'] = { top: component.colorT, bottom: component.colorB, left: component.colorL}
elementConfig1['mount'] = { x: component.mX, y: component.mY }