Created
March 25, 2014 05:01
-
-
Save bithavoc/9755523 to your computer and use it in GitHub Desktop.
Compile-Time file import in D
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import std.stdio; | |
template loadFile(string filePath, string accessorName) { | |
const char[] loadFile = "@property string " ~ accessorName ~ "() { return \"" ~ import(filePath) ~ "\";}"; | |
} | |
mixin(loadFile!("hello.txt", "contentOfHelloDotTxt")); | |
void main() | |
{ | |
writeln(contentOfHelloDotTxt); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment