1

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>
Paul Young
  • 1,489
  • 1
  • 15
  • 34
  • I created [this pull request](https://github.com/visionmedia/jade/pull/1195) to add a failing test which demonstrates the issue. – Paul Young Sep 14 '13 at 15:25
  • I want to confirm that the issue remains when no `include` is involved in layout.jade and the mixin is just written inline instead. – Paul Young Sep 20 '13 at 20:00

2 Answers2

0

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)
thtsigma
  • 4,878
  • 2
  • 28
  • 29
  • This does not work. I've added a comment on my question which demonstrates the issue when there is no include involved. – Paul Young Sep 20 '13 at 20:01
  • That's odd, it worked locally for me using that. I'll check it out later on tonight and try to replicate your error then fix it. – thtsigma Sep 20 '13 at 21:11
0

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.

Paul Young
  • 1,489
  • 1
  • 15
  • 34