dvibeddiet

What are aliases in vibe.d's Diet templates?


I can see in Vibed's Diet source code, the void compileDietString(string diet_code, ALIASES...)(OutputStream stream__) function.

I see it takes up to an infinite amount of aliases, as a template parameter.

What are these aliases? I have trouble figuring out through the source, it uses a lot of concepts like traits and mixins which I don't really understand that well.


Solution

  • These parameters are passed over from render and renderCompat. From the documentation of renderCompat:

    All following arguments must be pairs of a type and a string, each specifying one parameter. Parameter values can be passed either as a value of the same type as specified by the template arguments, or as a Variant which has the same type stored.

    Example:

    string title = "Hello, World!";
    int pageNumber = 1;
    res.renderCompat!("mytemplate.jd",
        string, "title",
        int, "pageNumber")
        (title, pageNumber);