Skip to content

Instantly share code, notes, and snippets.

@HerringtonDarkholme
Created January 21, 2015 04:46
Show Gist options
  • Save HerringtonDarkholme/7b1522575f5e58e5e077 to your computer and use it in GitHub Desktop.
Save HerringtonDarkholme/7b1522575f5e58e5e077 to your computer and use it in GitHub Desktop.
Jade: block statement in included components
block append test
h1 from comp1
block append test
h1 from comp2
block test
p begin of test
h1 from layout
block main
p from layout
<p>begin of test</p>
<h1>from layout</h1>
<h2>from comp2</h2>
<h1>from comp1</h1>
<h2>from view</h2>
<p>beging of main</p>
<h1>from comp1</h1>
<h2>from view</h2>
<h2>from comp2</h2>
<h1>from comp1</h1>
<h2>from view</h2>
<p>end of main</p>
<p>begin of test</p>
<h1>from layout</h1>
<h2>from view</h2>
<p>beging of main</p>
<h1>from comp1</h1>
<h2>from view</h2>
<h2>from comp2</h2>
<h2>from view</h2>
<p>end of main</p>
extends layout
block append test
h2 from view
block main
p beging of main
include comp1
include comp2
p end of main
@HerringtonDarkholme
Copy link
Author

Using block in include jade file is undefined behavior, according to the spec(or introduction) in jade-lang.

In jade1.9, content in block append ... section appears in the corresponding block section in layout, and at the same time appears immediately after the block append section.

In previous Jade(personally I tested 1.5) and php dialect, content in block append ... only appears at where it is defined but not inserted into its corresponding block section in layout.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment