-
Notifications
You must be signed in to change notification settings - Fork 488
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
Feature/interpolation #276
Conversation
const interpolate = (subject = '', params = {}, regexp, resolver) => { | ||
let shouldReplaceFull, found; | ||
|
||
const replaced = subject.replace(regexp, (full, matched) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a weird looking interpolation function, but it's been in my toolbelt for a while now. It allows you to preserve types when interpolating. e.g.
const subject = {
myField: '{{a}}',
myArray: '{{b}}'
}
interpolateDeep(
subject,
{
a: 1,
b: ['some','array']
}
)
// results in { myField: 1, myArray: ['some','array'] }
Usage is like this:
|
5f8b536
to
81b3c78
Compare
As pointed out in the related issue, the portion of this happening within conditions is already possible, and I would not recommend introducing a new syntax to accomplish the same thing. |
Closes #274. Allows rules to interpolate stuff from runtime facts by a configuration interpolation pattern.