2016-09-01 5 views

答えて

1

基本的に正しいですが、extendキーワードを使用するとブロック文を使用できますが、このレイアウトファイルまで拡張されたテンプレートファイル内のエクステンデットレイアウトからデフォルトブロックをオーバーライドできます。テンプレート内にキーワードincludeが含まれているすべての継承ファイルは、このブロック文も使用できます。すべてのここ

簡単な例

layout.jade

doctype html 
html(lang='de') 
    head 
    // Default meta block 
    block meta 
     meta(charset="utf-8") 
     title This is the pagetitle 

    // Default block for css assets 
    block styles 
     style. 
     .somecss { 
     } 
    body 
    // Default block for the navigation 
    block navigation 
     ul.my_default_nav 
     li: a(href="template.html") Navitem 

    // Default content block 
    block main 

    // Default footer block 
    block footer 
     p Some copyright notes 

template.jade

extend layout.jade 

block meta 
    title This block overrides the default block statement 

block footer 
    p You can place your block somewhere in your template, during 
    | compile jade knows where to place it. 

block main 
    div 
    p Here you can place your default content it also will be 
     | replaced. 

結果:

<!DOCTYPE html> 
<html lang="de"> 
    <head> 
    <!-- Default meta block--> 
    <title>This block overrides the default block statement</title> 
    <!-- Default block for css assets--> 
    <style> 
     .somecss { 
     } 
    </style> 
    </head> 
    <body> 
    <!-- Default block for the navigation--> 
    <ul class="my_default_nav"> 
     <li><a href="template.html">Navitem</a></li> 
    </ul> 
    <!-- Default content block--> 
    <div> 
     <p> 
     Here you can place your default content it also will bereplaced.</p> 
    </div> 
    <!-- Default footer block--> 
    <p> 
     You can place your block somewhere in your template, during compile jade knows where to place it.</p> 
    </body> 
</html>