Am 14.03.2013 13:40, schrieb Robert:

Okay what I meant with overriding was more in cases where you have a
layout.dt that is extended by another template. In a derived project you
then want to use a different layout.dt. This is out of reach of any
object oriented features or whatever means.

Ah, I see the extends syntax is the problem. :-) A not too bad solution would probably be to just call render functions (instead of defining blocks and extending it) in the layout.dt indirectly via delegates passed to the renderLayout method. I think I'll rewrite my current project this way and see how it works out. (The extends syntax did not scale very well for me anyway)

It would look something like this:
D code:
void renderLayout(HttpServerRequest req, HttpServerResponse res, RenderFunc contents, RenderFunc menu) {
mixin(renderDietFileMixin("project.layout.dt", res.bodyWriter));
}

project.layout.dt:

...
#menu

- menu(req, res);

#contents

- contents(req, res);


That will work, just the indentation of the HTML output will be messed
up (not that anyone will care...). But I actually like the way it is
possible to override for the extends way of doing things. No need for
delegates or classes.