Thread overview | ||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
August 08, 2017 Is it's possible to make modular pug template in vibed? | ||||
---|---|---|---|---|
| ||||
For example I am making simple site with header and footer. header and footer will be same for all pages. I do not want to do copy-paste it in every page. I want write it's once and than simpy import in every page. Is it's possible to do with vibed? |
August 08, 2017 Re: Is it's possible to make modular pug template in vibed? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Suliman | On Tuesday, 8 August 2017 at 11:55:09 UTC, Suliman wrote:
> For example I am making simple site with header and footer. header and footer will be same for all pages. I do not want to do copy-paste it in every page. I want write it's once and than simpy import in every page. Is it's possible to do with vibed?
Oh, I founded answer in docs.
|
August 08, 2017 Re: Is it's possible to make modular pug template in vibed? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Suliman | On Tuesday, 8 August 2017 at 11:59:38 UTC, Suliman wrote:
> On Tuesday, 8 August 2017 at 11:55:09 UTC, Suliman wrote:
>> For example I am making simple site with header and footer. header and footer will be same for all pages. I do not want to do copy-paste it in every page. I want write it's once and than simpy import in every page. Is it's possible to do with vibed?
>
> Oh, I founded answer in docs.
I can't fund way to `include` header and footer in the same docs. I cam getting error: "Includes cannot have children"
|
August 08, 2017 Re: Is it's possible to make modular pug template in vibed? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Suliman | On 8/8/17 8:38 AM, Suliman wrote:
> On Tuesday, 8 August 2017 at 11:59:38 UTC, Suliman wrote:
>> On Tuesday, 8 August 2017 at 11:55:09 UTC, Suliman wrote:
>>> For example I am making simple site with header and footer. header and footer will be same for all pages. I do not want to do copy-paste it in every page. I want write it's once and than simpy import in every page. Is it's possible to do with vibed?
>>
>> Oh, I founded answer in docs.
>
> I can't fund way to `include` header and footer in the same docs. I cam getting error: "Includes cannot have children"
This is probably because you have something like:
include myfile
hr // this is not allowed
The way I do it is this (learned from Kai's book):
layout.dt:
html
head
...
body
... // header here
block content
... // footer here
someview.dt:
extends layout
block content
... // your content
-Steve
|
August 08, 2017 Re: Is it's possible to make modular pug template in vibed? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Steven Schveighoffer | Yes, thanks what: extends layout mean? |
August 08, 2017 Re: Is it's possible to make modular pug template in vibed? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Suliman | Still can't get it work. include header .MainContainer .Header .HeaderMenu .HeaderBlock a(href="/") General .HeaderBlock a(href="/FAQ") FAQ .HeaderBlock a(href="/book") Book .HeaderLoginBlock Sign in .Middle foooo include footer it's template is compilable, but it have wrong indent. Original page (that I am trying to split) have next indents: doctype html html head title DLANG.ru body #app .MainContainer .Header .HeaderMenu .HeaderBlock router-link(to='/') General .HeaderBlock router-link(to='/FAQ') FAQ .HeaderBlock router-link(to='/book') Book .HeaderLoginBlock Sign in .Middle foooo .footer (c) DLANG 2017 But I can't get right indents when I am splition it. |
August 08, 2017 Re: Is it's possible to make modular pug template in vibed? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Suliman | On 8/8/17 9:10 AM, Suliman wrote:
> Yes, thanks what: extends layout mean?
It means that your final file will be layout.dt, but with the block statements replaced with the contents defined by the specific view file.
Think of it like an interface, where the "blocks" are function prototypes, and your specific view file is a class that implements the interface, where you implement the functions by defining the blocks.
-Steve
|
August 08, 2017 Re: Is it's possible to make modular pug template in vibed? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Steven Schveighoffer | On Tuesday, 8 August 2017 at 13:22:58 UTC, Steven Schveighoffer wrote:
> On 8/8/17 9:10 AM, Suliman wrote:
>> Yes, thanks what: extends layout mean?
>
> It means that your final file will be layout.dt, but with the block statements replaced with the contents defined by the specific view file.
>
> Think of it like an interface, where the "blocks" are function prototypes, and your specific view file is a class that implements the interface, where you implement the functions by defining the blocks.
>
> -Steve
Could you show how to improve my code above? I can't get it work...
|
August 08, 2017 Re: Is it's possible to make modular pug template in vibed? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Suliman | On 8/8/17 9:19 AM, Suliman wrote: > Still can't get it work. > > include header > ..MainContainer > ..Header > .HeaderMenu > .HeaderBlock > a(href="/") General > .HeaderBlock > a(href="/FAQ") FAQ > .HeaderBlock > a(href="/book") Book > .HeaderLoginBlock Sign in > ..Middle > foooo > include footer OK, you aren't thinking of this correctly then, each pug/diet file must be complete. It's not like C preprocessor where the structure can be played with via includes or macros. That is, .MainContainer cannot be a child under something defined in header. In this case, you need to use the block system. > it's template is compilable, but it have wrong indent. Original page (that I am trying to split) have next indents: > > doctype html > html > head > title DLANG.ru > body > #app > .MainContainer > .Header > .HeaderMenu > .HeaderBlock > router-link(to='/') General > .HeaderBlock > router-link(to='/FAQ') FAQ > .HeaderBlock > router-link(to='/book') Book > .HeaderLoginBlock Sign in > .Middle > foooo > .footer (c) DLANG 2017 > > But I can't get right indents when I am splition it. So what you want is probably like: layout.dt: doctype html html head title DLANG.ru body #app .MainContainer block contents .footer (c) DLANG 2017 myfile.dt: extends layout block contents .Header .HeaderMenu .HeaderBlock router-link(to='/') General .HeaderBlock router-link(to='/FAQ') FAQ .HeaderBlock router-link(to='/book') Book .HeaderLoginBlock Sign in .Middle foooo -Steve |
August 08, 2017 Re: Is it's possible to make modular pug template in vibed? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Steven Schveighoffer | Am I right understand that I can extend only one template? |
Copyright © 1999-2021 by the D Language Foundation