|
|
|
|
|
by mumblemumble
2110 days ago
|
|
I'd still prefer honest-to-goodness string interpolation. Formatting functions with positional placeholders need a linter to be kept (vaguely) maintainable, and I suspect that formatting functions with named placeholders would be difficult to make acceptably ergonomic or performant in Java. |
|
yamlp performs string interpolation from YAML files:
https://bitbucket.org/djarvis/yamlp/
I reuse my library in my text editor:
https://github.com/DaveJarvis/scrivenvar/
The text editor can interpolate strings in a variety of contexts (such as Markdown, R Markdown, XML, and R XML documents):
https://www.youtube.com/watch?v=u_dFd6UhdV8
As far as I can tell, there is no performance degradation from the recursive interpolation; the editor reads, interpolates key/value pairs, and substitutes the resulting values into R Markdown documents riddled with up to a thousand simple formulas in about 600 milliseconds (on my desktop computer).
Also, the editor provides a way to maintain the interpolated variables in a tree-like view:
https://github.com/DaveJarvis/scrivenvar/blob/master/README....
The substituted values appear in the preview pane in their final form. This is all real-time and pure Java.