1 import diet.html : compileHTMLDietString; 2 import std.array : appender, array; 3 import std.string : toUpper; 4 5 @dietTraits 6 static struct CTX { 7 static string translate(string text) { 8 return text == "Hello, World!" ? "Hallo, Welt!" : text; 9 } 10 11 static string filterUppercase(I)(I input) { 12 return input.toUpper(); 13 } 14 } 15 16 auto dst = appender!string; 17 dst.compileHTMLDietString!("p& Hello, World!", CTX); 18 assert(dst.data == "<p>Hallo, Welt!</p>"); 19 20 dst = appender!string; 21 dst.compileHTMLDietString!(":uppercase testing", CTX); 22 assert(dst.data == "TESTING");
Marks a struct as a Diet traits container.
A traits struct can contain any of the following: