-
Notifications
You must be signed in to change notification settings - Fork 239
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Substitute() nested variables #248
Comments
The
The |
Hey @silentmatt thanks for the reply. I know about To achieve this behaviour what I'm doing right now is to iterate over the expression const context = { a: 1, b: 2, c: 3 };
const expression = parser.parse('a + b + c');
const resolved = exp
.variables() // ['a', 'b', 'c']
.reduce((prevExp, v) => prevExp.substitute(v, context[v]), expression)
.toString();
console.log(resolved); // '1 + 2 + 3' This works great unless we have expressions with object references, like I was mentioning in the first post. |
Hello!
Just wondering if there is a way to use
substitute
to resolve object property references. For example:However, seems like the substitute mechanism is not able to interpolate it.
Hope you can help me on this. Thanks!
The text was updated successfully, but these errors were encountered: