Thread overview | ||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
May 06, 2015 vibed: how to use pure HTML instead of template engine? | ||||
---|---|---|---|---|
| ||||
By default vibed use Diet. Maybe it's cool, but for me it's easier to write in pure HTML. What is the best way to do it? |
May 06, 2015 Re: vibed: how to use pure HTML instead of template engine? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Suliman | On Wednesday, 6 May 2015 at 13:32:48 UTC, Suliman wrote: > By default vibed use Diet. Maybe it's cool, but for me it's easier to write in pure HTML. What is the best way to do it? You want to serve html files instead of templates, right? It should be something like router.get("*", serveStaticFiles("./public/")); Put your html stuff into the folder "public". |
May 06, 2015 Re: vibed: how to use pure HTML instead of template engine? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Chris | On Wednesday, 6 May 2015 at 13:50:04 UTC, Chris wrote: > On Wednesday, 6 May 2015 at 13:32:48 UTC, Suliman wrote: >> By default vibed use Diet. Maybe it's cool, but for me it's easier to write in pure HTML. What is the best way to do it? > > You want to serve html files instead of templates, right? It should be something like > > router.get("*", serveStaticFiles("./public/")); > > Put your html stuff into the folder "public". Cf. http://vibed.org/docs#http-routing |
May 06, 2015 Re: vibed: how to use pure HTML instead of template engine? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Chris | >> You want to serve html files instead of templates, right? It should be something like
Yeah, I do not see any profits with using templates right now. Explain me if I am wrong.
|
May 06, 2015 Re: vibed: how to use pure HTML instead of template engine? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Suliman | I mean that I know that template can be changes dynamically, but I thought that 99% of dynamic is javascript code... |
May 06, 2015 Re: vibed: how to use pure HTML instead of template engine? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Suliman | On Wednesday, 6 May 2015 at 14:07:09 UTC, Suliman wrote:
> I mean that I know that template can be changes dynamically, but I thought that 99% of dynamic is javascript code...
What if the user has Javascript disabled, or is using some client that doesn't execute Javascript (spiders and crawlers, wget, curl, ...)?
Not saying you have to support those cases, but it's something to consider.
|
May 06, 2015 Re: vibed: how to use pure HTML instead of template engine? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Suliman | On Wednesday, 6 May 2015 at 14:07:09 UTC, Suliman wrote: > I mean that I know that template can be changes dynamically, but I thought that 99% of dynamic is javascript code... Templates are like PHP, JSP, LSP etc. They can do stuff on the server side via embedded D code, load files for example. With JS you cannot do this. I think you should also be able to access variables set in query strings (?email=my@mail.com ...) and process them. But I'm not 100% sure about the latter. The user variables you get like this: void customHandler(HTTPServerRequest req, HTTPServerResponse res) { auto fields = req.query; // => ["email":"my@mail.com"]; } The drawback of templates is that you have to recompile them after each change atm, which is not very dynamic. Just have a look at http://vibed.org/templates/diet. |
May 06, 2015 Re: vibed: how to use pure HTML instead of template engine? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Chris | On Wednesday, 6 May 2015 at 14:21:24 UTC, Chris wrote: > On Wednesday, 6 May 2015 at 14:07:09 UTC, Suliman wrote: >> I mean that I know that template can be changes dynamically, but I thought that 99% of dynamic is javascript code... > > Templates are like PHP, JSP, LSP etc. They can do stuff on the server side via embedded D code, load files for example. With JS you cannot do this. I think you should also be able to access variables set in query strings (?email=my@mail.com ...) and process them. But I'm not 100% sure about the latter. The user variables you get like this: > > void customHandler(HTTPServerRequest req, HTTPServerResponse res) > { > auto fields = req.query; // => ["email":"my@mail.com"]; > } > > The drawback of templates is that you have to recompile them after each change atm, which is not very dynamic. > > Just have a look at http://vibed.org/templates/diet. Especially this: http://vibed.org/templates/diet#embedded-code |
May 06, 2015 Re: vibed: how to use pure HTML instead of template engine? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Chris | You can put that dynamic data in regular HTML too as long as you generate it on the server. I imagine vibe.d must support some kind of raw output write function, if you find that, you can make your html then just write it out as a string. |
May 06, 2015 Re: vibed: how to use pure HTML instead of template engine? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Chris | On Wednesday, 6 May 2015 at 14:23:27 UTC, Chris wrote:
> Especially this: http://vibed.org/templates/diet#embedded-code
I think that's a misfeature... if I used vibe.d, I'd want to avoid the diet too.
|
Copyright © 1999-2021 by the D Language Foundation