RejectedSoftware Forums

Sign up

Diet templates - Block and Extensions & Includes

Where can I find any information about "Block and Extensions & Includes" in diet templates? In the the diet documentation I can only find "TODO" and in the Jade documentation is not really much more information - "To Be Continued....". Here is some information about includes but seems that they don't work in diet. WTF?

Can anybody post some examples or a link with documentation?

Re: Diet templates - Block and Extensions & Includes

On 2014-01-17 8:56 AM, Anton Alexeev wrote:

Where can I find any information about "Block and Extensions & Includes" in diet templates? In the the diet documentation I can only find "TODO" and in the Jade documentation is not really much more information - "To Be Continued....". Here is some information about includes but seems that they don't work in diet. WTF?

Can anybody post some examples or a link with documentation?

The more useful examples are in userman.
https://github.com/rejectedsoftware/userman/tree/master/views

I've never tried includes, I think extends and blocks can serve that
purpose. You make your diet template "extends file" without .dt. This
file has to have code you want to include, and so you specify the "block
name" command at the place of inclusion.

In the end, you know you're including or defining the block only if
there's text indented further under it (defines) or no text indented
further (includes).

e.g.

Filename: "myproject.something.dt"

block content

h1 Welcome!
p This is some content.

This file includes:

extends myproject.something

!!! 5
html

 head
         title hello

body

block content

Re: Diet templates - Block and Extensions & Includes

On Fri, 17 Jan 2014 13:56:55 GMT, Anton Alexeev wrote:

Where can I find any information about "Block and Extensions & Includes" in diet templates? In the the diet documentation I can only find "TODO" and in the Jade documentation is not really much more information - "To Be Continued....". Here is some information about includes but seems that they don't work in diet. WTF?

Can anybody post some examples or a link with documentation?

An example of an include is in DDOX, used for inserting the right kind of module index:
https://github.com/rejectedsoftware/ddox/blob/master/views/ddox.layout.dt#L10

Re: Diet templates - Block and Extensions & Includes

Fixed formatting and order of the example:

Filename: "myproject.something.dt"

!!! 5
html
    head
        title hello
body
    block content

This file includes:

extends myproject.something

block content
    h1 Welcome!
    p This is some content.