RejectedSoftware Forums

Sign up

Pages: 1 2

diet-ng output all on one line

Hello, I ran a simple HTML hello world using vibe.d configured to use 0.7.30 and diet-ng 1.1 in the way indicated in the diet-ng article mentioned in http://vibed.org/blog/posts/introducing-diet-ng .

When I viewed source in Firefox/Linux all of the HTML was on one line, unlike the example here. My template was very simple.

doctype html
html

head
    title Greetings from vibe.d
body
    Hello World

But view source in Firefox showed all html generated from this on one line, not laid out neatly with indentation for the tags as in the link above. How can I get that indentation?

Re: diet-ng output all on one line

Am 09.11.2016 um 23:51 schrieb Carl Sturtivant:

Hello, I ran a simple HTML hello world using vibe.d configured to use 0.7.30 and diet-ng 1.1 in the way indicated in the diet-ng article mentioned in http://vibed.org/blog/posts/introducing-diet-ng .

When I viewed source in Firefox/Linux all of the HTML was on one line, unlike the example here. My template was very simple.

doctype html
html

head
    title Greetings from vibe.d
body
    Hello World

But view source in Firefox showed all html generated from this on one line, not laid out neatly with indentation for the tags as in the link above. How can I get that indentation?

You can define a special traits struct (multiple such structs can be
defined) to configure the behavior, including how the output is formatted:

import diet.traits;
@dietTraits struct Traits {
     enum htmlOutputStyle = HTMLOutputStyle.pretty;
}

render!("index.dt", Traits);

I'll probably add a version that can be used to change this behavior
globally for vibe.d, without having to define traits.

Re: diet-ng output all on one line

On Thu, 10 Nov 2016 09:38:45 +0100, Sönke Ludwig wrote:

You can define a special traits struct (multiple such structs can be
defined) to configure the behavior, including how the output is formatted:

import diet.traits;
@dietTraits struct Traits {
     enum htmlOutputStyle = HTMLOutputStyle.pretty;
}

render!("index.dt", Traits);

I'll probably add a version that can be used to change this behavior
globally for vibe.d, without having to define traits.

Looks good, thanks, and now I found it in the docs produced by dub. (It also needs diet.html to be imported for HTMLOutputStyle.)

However, I am unclear how to use the above struct with staticTemplate rather than render, as the first seems to only exist with one compile-time parameter. Of course I can recode using render, so this is a very minor matter.

Re: diet-ng output all on one line

Am 11.11.2016 um 22:21 schrieb Carl Sturtivant:

On Thu, 10 Nov 2016 09:38:45 +0100, Sönke Ludwig wrote:

You can define a special traits struct (multiple such structs can be
defined) to configure the behavior, including how the output is formatted:

import diet.traits;
@dietTraits struct Traits {
     enum htmlOutputStyle = HTMLOutputStyle.pretty;
}

render!("index.dt", Traits);

I'll probably add a version that can be used to change this behavior
globally for vibe.d, without having to define traits.

Looks good, thanks, and now I found it in the docs produced by dub. (It also needs diet.html to be imported for HTMLOutputStyle.)

However, I am unclear how to use the above struct with staticTemplate rather than render, as the first seems to only exist with one compile-time parameter. Of course I can recode using render, so this is a very minor matter.

I think I'll turn the default around and make it output pretty by
default. Version VibeOutputCompactHTML can then be used to output
minimized.

Re: diet-ng output all on one line

On Mon, 19 Dec 2016 09:36:09 +0100, Sönke Ludwig wrote:

Am 11.11.2016 um 22:21 schrieb Carl Sturtivant:

On Thu, 10 Nov 2016 09:38:45 +0100, Sönke Ludwig wrote:

You can define a special traits struct (multiple such structs can be
defined) to configure the behavior, including how the output is formatted:

import diet.traits;
@dietTraits struct Traits {
     enum htmlOutputStyle = HTMLOutputStyle.pretty;
}

render!("index.dt", Traits);

I'll probably add a version that can be used to change this behavior
globally for vibe.d, without having to define traits.

Looks good, thanks, and now I found it in the docs produced by dub. (It also needs diet.html to be imported for HTMLOutputStyle.)

However, I am unclear how to use the above struct with staticTemplate rather than render, as the first seems to only exist with one compile-time parameter. Of course I can recode using render, so this is a very minor matter.

I think I'll turn the default around and make it output pretty by
default. Version VibeOutputCompactHTML can then be used to output
minimized.

Implemented now: 2db5145

Re: diet-ng output all on one line

On Mon, 19 Dec 2016 08:55:27 GMT, Sönke Ludwig wrote:

I think I'll turn the default around and make it output pretty by
default. Version VibeOutputCompactHTML can then be used to output
minimized.

Implemented now: 2db5145

Very nice.

Re: diet-ng output all on one line

On Thu, 29 Dec 2016 02:40:46 GMT, Carl Sturtivant wrote:

Implemented now: 2db5145

Very nice.

OK, so I moved the project up to

dependency "vibe-d" version="~>0.8.0-beta.1"
dependency "diet-ng" version="~>1.1"
subConfiguration "vibe-d:core" "vibe-core"

and it built under 0.8.0-beta.3.

I took a look at the by-default-pretty HTML output from a template and noticed that the head of the document was not pretty, but rather the tags were all on one line, while the body was indeed pretty.

Is this what you intended?

Also, a small stylesheet definition embedded in the head with :css appeared nicely but the style tags were not indented, and the css itself was indented only relative to the style tags, not to the current level of indentation.

Perhaps this is what's intended...?

Re: diet-ng output all on one line

Am 12.02.2017 um 20:54 schrieb Carl Sturtivant:

On Thu, 29 Dec 2016 02:40:46 GMT, Carl Sturtivant wrote:

Implemented now: 2db5145

Very nice.

OK, so I moved the project up to

dependency "vibe-d" version="~>0.8.0-beta.1"
dependency "diet-ng" version="~>1.1"
subConfiguration "vibe-d:core" "vibe-core"

and it built under 0.8.0-beta.3.

I took a look at the by-default-pretty HTML output from a template and noticed that the head of the document was not pretty, but rather the tags were all on one line, while the body was indeed pretty.

Is this what you intended?

Also, a small stylesheet definition embedded in the head with :css appeared nicely but the style tags were not indented, and the css itself was indented only relative to the style tags, not to the current level of indentation.

Perhaps this is what's intended...?

Definitely not intended. In case of text filters, pretty printing is
simply not implemented, but the head case sounds strange. Can you post a
short snippet that reproduces the issue?

Re: diet-ng output all on one line

On Mon, 13 Feb 2017 13:33:32 +0100, Sönke Ludwig wrote:

Definitely not intended. In case of text filters, pretty printing is
simply not implemented, but the head case sounds strange. Can you post a
short snippet that reproduces the issue?

main.dt

extends layout
block title
    title Not a pretty HEAD
block header
    meta(author="Fred")
block content
    p   Blah

layout.dt

doctype html
html(lang="en")
    head
        meta(charset="utf-8")
        block title
        meta(name="viewport", content="width=device-width, initial-scale=1")
        link(rel="stylesheet", href="css/sheet.css")
        block header
        :css
            .navlink {
                display: inline-block;
            }
    body
        block content

dub.sdl

#...
dependency "vibe-d" version="~>0.8.0-beta.1"
dependency "diet-ng" version="~>1.1"
subConfiguration "vibe-d:core" "vibe-core"
versions "VibeDefaultMain"

DUB version 1.2.0, built on Jan 22 2017
DMD64 D Compiler v2.073.0
Linux carl 4.4.0-62-generic #83-Ubuntu SMP Wed Jan 18 14:10:15 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux

app.d

import vibe.vibe;

shared static this()
{
    auto router = new URLRouter;
    router.get("/", staticTemplate!"main.dt");
    
    auto settings = new HTTPServerSettings;
    settings.port = 8080;
    settings.bindAddresses = ["::1", "127.0.0.1"];
    listenHTTP(settings, router);

    logInfo("Please open http://127.0.0.1:8080/ in your browser.");
}

Resulting output showing single wrapped line in the head, part from layout.dt and part from main.dt:

<!DOCTYPE html>
<html lang="en">
	<head>
		<meta charset="utf-8"/><title>Not a pretty HEAD</title><meta name="viewport" content="width=device-width, initial-scale=1"/><link rel="stylesheet" href="css/normalize.css"/><meta author="Fred"/>

<style type="text/css"><!--
	.navlink {
	    display: inline-block;
	    padding-right: 10px;
	}
--></style>
	</head>
	<body>
		<p>  Blah</p>
	</body>
</html>

Re: diet-ng output all on one line

On Mon, 13 Feb 2017 19:16:45 GMT, Carl Sturtivant wrote:

On Mon, 13 Feb 2017 13:33:32 +0100, Sönke Ludwig wrote:

Definitely not intended. In case of text filters, pretty printing is
simply not implemented, but the head case sounds strange. Can you post a
short snippet that reproduces the issue?

(...)

Thanks! Has been fixed now: #18

Pages: 1 2