May 06, 2015 Re: vibed: how to use pure HTML instead of template engine? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Adam D. Ruppe | On Wednesday, 6 May 2015 at 14:28:26 UTC, Adam D. Ruppe wrote:
> 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.
I agree
|
May 06, 2015 Re: vibed: how to use pure HTML instead of template engine? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Adam D. Ruppe | On Wednesday, 6 May 2015 at 14:28:26 UTC, Adam D. Ruppe wrote: > 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. I have never used the templates. Usually I generate the HTML myself, if its dynamic stuff, and send it back to the user as via res.writeBody: auto html = someStringActions(); res.writeBody(cast(ubyte[])html); For static pages I route to serverStaticFiles. |
May 06, 2015 Re: vibed: how to use pure HTML instead of template engine? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Chris | > auto html = someStringActions();
> res.writeBody(cast(ubyte[])html);
Thanks, but how to attach to html css file? Now page is loading, but do not handle css that also placed in this folder.
|
May 06, 2015 Re: vibed: how to use pure HTML instead of template engine? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Suliman | And how people write in jade if it's impossible to preview page without compiling it's to HTML? |
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 18:52:41 UTC, Suliman wrote:
>> auto html = someStringActions();
>> res.writeBody(cast(ubyte[])html);
>
> Thanks, but how to attach to html css file? Now page is loading, but do not handle css that also placed in this folder.
CSS should be exported automatically when you use serveStaticFiles. I don't understand what exactly you mean. If you send a string
<html>
...
</htm>
the browser automatically detects the CSS file you link to and will get it from vibe.d If the CSS is embedded in the HTML (via <style></style> the browser will recognize this.
|
May 06, 2015 Re: vibed: how to use pure HTML instead of template engine? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Adam D. Ruppe | On Wednesday, 6 May 2015 at 14:28:26 UTC, Adam D. Ruppe wrote:
> 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.
I quite like them. Obviously one can get too carried away, but overall they've been useful for me, especially when I'm working to very tight deadlines.
|
May 06, 2015 Re: vibed: how to use pure HTML instead of template engine? | ||||
---|---|---|---|---|
| ||||
Posted in reply to John Colvin | On Wednesday, 6 May 2015 at 20:45:10 UTC, John Colvin wrote:
> On Wednesday, 6 May 2015 at 14:28:26 UTC, Adam D. Ruppe wrote:
>> 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.
>
> I quite like them. Obviously one can get too carried away, but overall they've been useful for me, especially when I'm working to very tight deadlines.
I agree that this is misfeature but mostly because it makes impossible switching template generation to runtime during development for faster edit/compile cycles.
|
May 07, 2015 Re: vibed: how to use pure HTML instead of template engine? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Dicebot | Is next example is enough to serv simple index.html page? void setupServer() { auto router = new URLRouter; // add other routes here router.get("*", serveStaticFiles("public/")); auto settings = new HTTPServerSettings; listenHTTP(settings, router); } After it's run I open localhost:8080 but browser say that can't connect to the page. |
May 07, 2015 Re: vibed: how to use pure HTML instead of template engine? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Suliman | On Thursday, 7 May 2015 at 08:09:50 UTC, Suliman wrote:
> Is next example is enough to serv simple index.html page?
>
> void setupServer()
> {
> auto router = new URLRouter;
> // add other routes here
> router.get("*", serveStaticFiles("public/"));
>
> auto settings = new HTTPServerSettings;
> listenHTTP(settings, router);
> }
>
> After it's run I open localhost:8080 but browser say that can't connect to the page.
You're not setting a port.
add:
settings.port = 8080;
before listenHTTP();
then it'll work.
|
Copyright © 1999-2021 by the D Language Foundation