vibe.d: is it possible to use bare HTML with the functionalty of DIET templates ?
Steven Schveighoffer
schveiguy at gmail.com
Tue Aug 31 14:06:32 UTC 2021
On 8/30/21 8:09 PM, someone wrote:
> Regarding vibe.d I think I'll give it a try (maybe placing it behind
> nginx at first) since I do really got a good first-impression ... kudos
> to the developers/maintainers :)
>
> I like the idea of having D at my disposal within a web page, actually,
> it is a terrific feature to say the least.
>
> What I do not like (even a bit) are the pseudo-HTML DIET templates. I
> can understand they can make life easy for some, but I am not the guy
> having any trouble writing well-good-structured HTML/XHTML/XML/etc to
> begin with, nor I am the kind of guy grunting because I will be forced
> to write closing tags and the like.
>
> That being said, my specific question is:
>
> Can I use vibe.d *without* DIET templates manually writing say, XHTML
> 1.1 pages, *while having D* at my disposal with the - prefixes I have
> seen so far ?
The generation of code to output the page depends on the diet file
format (i.e. code islands are designated by the leading `-`).
However, vibe-d does not require using the diet template system. There
are others which probably do what you want (search on code.dlang.org),
but I'm a huge fan of diet templates (I actually prefer writing
non-template html that way), so I don't have any experience with others.
Given how templating systems work (and how D allows strings to be used
as code using mixins), it's likely pretty trivial to write a simple
templating system to do this. All you need is an escape protocol that is
unlikely to appear in HTML, and you can probably get away with a 10 line
function that doesn't need to actually parse the HTML.
-Steve
More information about the Digitalmars-d-learn
mailing list