On Wed, 08 May 2013 15:26:26 GMT, Michal Minich wrote:

Thank you for fast response, now I see more members in docs and also base classes. The combination of .contentType and .bodyWriter properties works well for me.

I'm quite surprised by the limitation of .dt templates, I was hoping to use them for JSON / plain text and some other formats generation. I guess it would be quite useful.

This attempt to generate JSON in .dt failed

[

  • foreach (b; bs)
    {"key":#{b.id}}

]

I would consider this code more elegant than writing string to streams and I would very much liked if .dt would not be limited to html

also it generates text/html content type, even if I explicitly set "application/json" in app code just before rendering template.

I think the closest to what you would need for this is embd (basically the same concept, just completely format agnostic), I would give it a try! The Diet templates are a variation of Jade/Haml and have a lot of features that are very specific to the syntax and structure of HTML. This limits them of course, but also allows them to be much more terse/clean than a generic format. I think both kinds of templates have their place after all.