On Thursday, 2 November 2017 at 18:51:09 UTC, bauss wrote:
On Thursday, 2 November 2017 at 18:48:10 UTC, bauss wrote:

Before you did:
render!("index.dt", title, major_categories);

Have you tried to check the contents of "major_categories" making sure it's all there. Just to figure out whether the problem is in the view rendering or the json parsing.

I checked, it seemed as though the JSON was all there.

Also alternatively have you tried "vibe.data.json"?

http://vibed.org/api/vibe.data.json/

I just converted my code to use vibe's library instead of the phobos Json implementation.

Now I'm not getting any output whatsoever. I'm wondering if it's an issue with Diet not wanting to do that many levels of nested iterations...

Also the vibe.data.json.Json.toString() method does something awful to that Json string. After I fix that I might be able to get more debugging info...

Here's my Diet. I basically just pass a Json object to render!:

doctype html
html
    head
        title #{json["title"].get!string}
    body
        - import std.stdio : writeln;
        - import vibe.data.json : Json;
        h1 #{json["title"].get!string}

        - foreach (major; json["major_categories"].get!(Json[])) {
- string major_category_name = major["title"].get!string;
            - major_category_name.writeln();
            h2 #{major_category_name}
            - foreach (minor; major["categories"].get!(Json[])) {
                h4 #{minor["title"].get!string}
                p
- foreach (item; minor["links"].get!(Json[])) { a(href="#{item[\"url\"].get!string}") #{item["label"].get!string}
                        br
                    - }
            - }
        - }

Reply via email to