source: appstream-generator/contrib/subprojects/mustache-d-0.1.3/example/projects.d @ 4841

Last change on this file since 4841 was 4841, checked in by Juanma, 2 years ago

Initial release

File size: 1.1 KB
Line 
1// This example from https://github.com/defunkt/mustache/blob/master/examples/projects.mustache
2
3import mustache;
4import std.stdio;
5
6struct Project
7{
8    string name;
9    string url;
10    string description;
11}
12
13static Project[] projects = [
14    Project("dmd", "https://github.com/dlang/dmd", "dmd D Programming Language compiler"),
15    Project("druntime", "https://github.com/dlang/druntime", "Low level runtime library for the D programming language"),
16    Project("phobos", "https://github.com/dlang/phobos", "The standard library of the D programming language")
17];
18
19void main()
20{
21    alias MustacheEngine!(string) Mustache;
22
23    Mustache mustache;
24    auto context = new Mustache.Context;
25
26    context["width"] = 4968;
27    foreach (ref project; projects) {
28        auto sub = context.addSubContext("projects");
29        sub["name"]        = project.name;
30        sub["url"]         = project.url;
31        sub["description"] = project.description;
32    }
33
34    mustache.path  = "example";
35    mustache.level = Mustache.CacheLevel.no;
36    stdout.rawWrite(mustache.render("projects", context));
37}
Note: See TracBrowser for help on using the repository browser.