|
@@ -12,11 +12,15 @@ import vibe.core.log;
|
|
|
|
|
|
import std.stdio;
|
|
|
import std.string;
|
|
|
+//import std.array;
|
|
|
+
|
|
|
|
|
|
import memcached4d;
|
|
|
|
|
|
import std.conv : to;
|
|
|
|
|
|
+import mustache;
|
|
|
+alias MustacheEngine!(string) Mustache;
|
|
|
|
|
|
|
|
|
|
|
@@ -129,7 +133,39 @@ void test(HTTPServerRequest req, HTTPServerResponse res){
|
|
|
|
|
|
writeln(cache.del("test1"));
|
|
|
|
|
|
- res.writeBody("Hello, World!\n" ~ result);
|
|
|
+
|
|
|
+
|
|
|
+ Mustache mustache2;
|
|
|
+ auto context2 = new Mustache.Context;
|
|
|
+ mustache2.path = "priv/folder2";
|
|
|
+ mustache2.ext = "dtl";
|
|
|
+
|
|
|
+ context2["param2"] = "blah blah blah ";
|
|
|
+
|
|
|
+ Mustache mustache;
|
|
|
+ auto context = new Mustache.Context;
|
|
|
+ mustache.path = "priv";
|
|
|
+ mustache.ext = "dtl";
|
|
|
+
|
|
|
+ //context.useSection("boolean");
|
|
|
+ //assert(mustache.renderString(" {{#boolean}}YES{{/boolean}}\n {{#boolean}}GOOD{{/boolean}}\n", context) == " YES\n GOOD\n");
|
|
|
+
|
|
|
+ //{{#repo}}<b>{{name}}</b>{{/repo}}
|
|
|
+ //{{^repo}}No repos :({{/repo}}
|
|
|
+ // to
|
|
|
+ //No repos :(
|
|
|
+
|
|
|
+ context["lang"] = "en";
|
|
|
+ context["number1"] = 42;
|
|
|
+ context.useSection("maybe1");
|
|
|
+
|
|
|
+ context["part1"] = mustache2.render("part1", context2);
|
|
|
+ context["result1"] = "Hello, World!\n" ~ result;
|
|
|
+
|
|
|
+ res.headers["Content-Type"] = "text/html; charset=utf-8";
|
|
|
+
|
|
|
+ //res.writeBody("Hello, World!\n" ~ result);
|
|
|
+ res.writeBody( mustache.render("main", context) );
|
|
|
}
|
|
|
|
|
|
|