digitalmars.D.learn - Dynamic Template-Expansion of (Token) Strings
- Per =?UTF-8?B?Tm9yZGzDtnc=?= (10/10) Oct 27 2020 I'm looking for elegant ways of expressing expansion of
- Jacob Carlborg (7/17) Oct 27 2020 You might want to have a look at Mustache [1]. Here's a Dub
- Per =?UTF-8?B?Tm9yZGzDtnc=?= (2/4) Oct 27 2020 Thanks
I'm looking for elegant ways of expressing expansion of parameterized strings written to a file at run-time. My primary use case is run-time generation of D code. In the lazy case, something like import std.file : write; import std.algorithm : substitute; const s = q{int $X = $Y;}; // templated source foreach (part; s.substitute("$X", "x", "$Y", "42")) write(somePath, part); is my current best bet.
Oct 27 2020
On Tuesday, 27 October 2020 at 08:33:08 UTC, Per Nordlöw wrote:I'm looking for elegant ways of expressing expansion of parameterized strings written to a file at run-time. My primary use case is run-time generation of D code. In the lazy case, something like import std.file : write; import std.algorithm : substitute; const s = q{int $X = $Y;}; // templated source foreach (part; s.substitute("$X", "x", "$Y", "42")) write(somePath, part); is my current best bet.You might want to have a look at Mustache [1]. Here's a Dub package [2]. [1] http://mustache.github.io/mustache.5.html [2] https://code.dlang.org/packages/mustache-d -- /Jacob Carlborg
Oct 27 2020
On Tuesday, 27 October 2020 at 10:46:42 UTC, Jacob Carlborg wrote:[1] http://mustache.github.io/mustache.5.html [2] https://code.dlang.org/packages/mustache-dThanks
Oct 27 2020