-
-
Notifications
You must be signed in to change notification settings - Fork 61
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
Fix various issues with templates and variables #153
base: master
Are you sure you want to change the base?
Conversation
@ildar170975 |
Hi Paul. |
Fixes iantrich#93, Closes iantrich#119, Closes iantrich#147 (This eliminates the need for iantrich#119 and iantrich#147)
If multiple variables are defined then subsequent variables can currently reference prior variables using `vars['name']` but not just `name`. This enables variables to reference prior variables by name, like templates can.
(I merged #148 here, since it is necessary to fix the build issues.) |
This looks great! currently running this pr with no issues. |
config[key] = this._evaluateConfig(value); | ||
}); | ||
} else if (typeof config === 'string' && config.includes('${')) { | ||
return _evaluateTemplate(config); |
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.
did you mean this._evaluateTemplate
? I'm getting a compile error here.
return eval(template.substring(2, template.length - 1)); | ||
} | ||
|
||
template.match(/\${[^}]+}/g).forEach(m => { |
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.
the match may be null
giving another compile error. can we maybe do this?
const matches = template.match(/\${[^}]+}/g);
if (matches) {
matches.forEach(m => {
const repl = eval(m.substring(2, m.length - 1));
template = template.replace(m, repl);
});
}
See the individual commit messages for details.
Fixes #93, Closes #110, Closes #119, Closes #147, Closes #148
(This includes/supersedes #110 and #148, and eliminates the need for #119 and #147)