RejectedSoftware Forums

Sign up

Recursive layouts?

Hello there!

I'm new to vibe.d and enjoying it so far.

But I would like to know whether recursive layouts are implemented, or if I am doing something wrong. Here's a snippet of what I'm attempting:

(layout.dt)

!!! 5
html
    head
        block title
        link(rel="stylesheet", type="text/css", href="css/bootstrap.min.css")
        block styles
    body
        block body
        script(src="http://code.jquery.com/jquery-latest.js")
        script(src="js/bootstrap.min.js")
        block scripts

(layout_modal.dt)

extends layout

block body
    .modal
        .modal-header
            block modal-header
        .modal-body
            block modal-body
        .modal-footer
            block modal-footer

(error.dt)

extends layout_modal

block title
    title Error

block modal-body
    #{error.message}

I will change these to use default block contents once they're implemented.

Thank you for your attention, Matej

Re: Recursive layouts?

Bah! I wasn't using the newest vibe.d version. Now the compile doesn't fail anymore (it did before, saying the template didn't start with "!!! 5"; forgot to mention that).

But, instead, the blocks filled in the rendered page aren't filled in the result.

Sorry for the last example, I've since noticed the syntax was wrong in a few parts and have updated them. I'll also write a smaller example here, to hopefully outline my intentions better.

Here goes:

layout.dt

!!! 5
html
    head
        block title
        link(rel="stylesheet", type="text/css", href="css/bootstrap.min.css")
    body
        block body

layout_modal.dt

extends layout

block body
    .modal
        .modal-header
            block modal-header
        .modal-body
            block modal-body
        .modal-footer
            block modal-footer

login.dt

extends layout_modal

block title
    title Test page

block modal-header
    h2 Test Page

block modal-body
    p Some kind of form will be put here.

So, the result of this is as if I were rendering layout_modal.dt directly. Seems like login.dt is ignored? (The title doesn't get set either.) I'm 100 % certain that I'm actually calling .render!("login.dt") and not layout_modal.dt.

Thanks!

Re: Recursive layouts?

Am 10/14/2012 1:28 AM, schrieb Matej Nanut:

Bah! I wasn't using the newest vibe.d version. Now the compile doesn't
fail anymore (it did before, saying the template didn't start with "!!!

But, instead, the blocks filled in the rendered page aren't filled in
the result.

Sorry for the last example, I've since noticed the syntax was wrong in a
few parts and have updated them. I'll also write a smaller example here,
to hopefully outline my intentions better.

Here goes:

layout.dt

!!! 5
html
   head
       block title
       link(rel="stylesheet", type="text/css",
href="css/bootstrap.min.css")
   body
       block body

layout_modal.dt

extends layout

block body
   .modal
       .modal-header
           block modal-header
       .modal-body
           block modal-body
       .modal-footer
           block modal-footer

login.dt

extends layout_modal

block title
   title Test page

block modal-header
   h2 Test Page

block modal-body
   p Some kind of form will be put here.

So, the result of this is as if I were rendering layout_modal.dt
directly. Seems like login.dt is ignored? (The title doesn't get set
either.) I'm 100 % certain that I'm actually calling
.render!("login.dt") and not layout_modal.dt.

Thanks!

There was a bug in the parser that caused recursive block definitions to
be ignored - unfortunately fixing this was a bit more involved than it
should have been, because, for some reason, I constantly hit compiler
bugs...

But it's fixed now on master (at least the example works correctly)

Re: Recursive layouts?

Oh, wow!

Now that is some speed.

Thanks a lot! This is amazing!

goes hacking away