Skip to content

Commit

Permalink
Use plain string replacement
Browse files Browse the repository at this point in the history
  • Loading branch information
chances committed Feb 25, 2024
1 parent dea209f commit 339d1bd
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
14 changes: 10 additions & 4 deletions docs/process.d
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,14 @@
/// License: MIT License
module wgpu.docs.process;

import handlebars.tpl;
static import std.file;
import std.process;
import std.stdio;

void main(string[] args) {
import std.array : replace;
import std.string : strip;

string template_ = std.file.readText("views/index.hbs");

struct Constants {
Expand All @@ -21,7 +23,11 @@ void main(string[] args) {

auto gitTagCmd = execute(["git", "describe", "--tags", "--abbrev=0"]);
assert(gitTagCmd.status == 0);
gitTagCmd.output.writeln;
auto result = render(template_, Constants(gitTagCmd.output));
result.writeln;
gitTagCmd.output.write;

const constants = Constants(gitTagCmd.output.strip);
const result = template_.replace("{{ DUB_VERSION }}", constants.DUB_VERSION);

if (std.file.exists("docs/index.html")) std.file.remove("docs/index.html");
std.file.write("docs/index.html", result);
}
1 change: 0 additions & 1 deletion dub.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
},
"dflags": ["-Dddocs"],
"postBuildCommands-posix": [
"dub fetch handlebars",
"rdmd -I~/.dub/packages/handlebars/0.3.1/handlebars/source docs/process.d"
]
}
Expand Down

0 comments on commit 339d1bd

Please sign in to comment.