๐ชInheritance (Extending)
If multiple of your files have a repetitive structure, you can define a template that your other files can extend. Templates can even extend other templates.
In your template you can define several blocks which you can then fill in the extending file.
block vars
  - lang := "en"
html(lang=lang)
head
  link(rel="stylesheet", href="/foo.css")
  title: block title
  block head
body: block bodyextend "github.com/me/myproject/corgi/base.corgi"
block title Learn Corgi
block body
  p
    > Head over to
      #a(href="https://mavolin.gitbook.io/corgi")[GitBook]
      to learn corgi!
<!doctype html>
<html lang="en">
<head>
  <link rel="stylesheet" href="/foo.css">
  <title>Learn Corgi</title>
</head>
<body>
  <p>
    Head over to
    <a href="https://mavolin.gitbook.io/corgi">GitBook</a>
    to learn corgi!
  </p>
</body>
</html>extend "base"
append vars
  - lang = "de"
  
block title Lerne Corgi
append head: link(rel="stylesheet", href="/fooz.css")
block body
  p 
    > Schau bei
      #a(href="https://mavolin.gitbook.io/corgi")[GitBook]
      vorbei, um corgi zu lernen!
<!doctype html>
<html lang="de">
<head>
  <link rel="stylesheet" href="/foo.css">
  
  <title>Lerne Corgi</title>
  <link rel="stylesheet" href="/fooz.css">
</head>
<body>
  <p>
    Schau auf
    <a href="https://mavolin.gitbook.io/corgi">GitBook</a>
    vorbei, um corgi zu lernen!
  </p>
</body>
</html>Last updated
Was this helpful?