in Jade, how I can output the contents of an `extends` block inside of a mixin?

564 views Asked by At

How I can output the contents of an extends block inside of a mixin?

This is a simplified example:

mixins.jade

mixin form()
  form
    block

layout.jade

include mixins.jade

body
  +form
    block content

somepage.jade

extends layout
block content
  input(type=text)

Here I would like to achieve:

<form>
  <input type="text"></input>
</form>

But currently all I get is:

<form></form>
2

There are 2 answers

0
Paul Young On BEST ANSWER

The fact that did not work was identified as a bug after I had created a GitHub issue and submitted a failing spec.

Per this pull request it's now possible to do what I described in my original question but as stated, this currently only works in the development branch of Jade and will be a part of the next release.

2
thtsigma On

Try something along these lines:

layout.jade

doctype 5
  head 
    title "Title"
  body
    block content
      include mixins.jade
      +form
        block

SomePage.jade

extends layout
block content
  input(type=text)