Skip to content
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

Add interpolation to Config objects #23

Merged
merged 3 commits into from Oct 24, 2018
Merged

Conversation

greg-1-anderson
Copy link
Member

This PR interpolates values into tokens delimited by double-curley braces.

Example: $config->interpolate('This is a {{a.b.c}} bar');

This is a departure from how variables are defined and substituted at parsing time, where ${name} is used instead. It would be possible to be consistent, but consistency would make it harder to pull strings out of configuration and use them as interpolation templates. I'm not sure if this use-case is important or desirable.

@greg-1-anderson
Copy link
Member Author

Also, I made this an interface / trait to make for easier calling, e.g. $siteAlias->interpolate(...). However, the downside to this implementation is that there's no way to call interpolate if you have an object that implements ConfigInterface but does not use the interpolate trait. Maybe I should make a utility class:

$interpolator = new InterpolateUtil();
$result = $interpolator->interpolate($siteAlias, $message);

Maybe I should do both.

@greg-1-anderson
Copy link
Member Author

I did both.

@greg-1-anderson greg-1-anderson merged commit 925231d into master Oct 24, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant