Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

include and block #997

Closed
cooolbasha opened this issue Apr 28, 2013 · 13 comments
Closed

include and block #997

cooolbasha opened this issue Apr 28, 2013 · 13 comments

Comments

@cooolbasha
Copy link

I have a layout.jade

layout.jade

block scripts

block content

i have page1.jade

extends layout
append scripts
  :coffeescript
    console.log "page1"

append content
  p page 1
  include page2
  append scripts
    :coffeescript
        console.log "this work fine appended to the top of the page /script..but it is repeated with the previous script"

and page2.jade is

append scripts
  :coffeescript 
     console.log "page 2"
append content
     p page2

the included page comes with the script at the end of page1 not at the top of the page1 along with other scripts..The script after the include page is added to to the top of page(and it is added once more again??). should not the page2 be included and then the extension be applied so that we can same behavior as .other append right after the include.

@vendethiel
Copy link
Contributor

Please format the code using `````

@ForbesLindesay
Copy link
Member

I've added formatting (yay for being able to edit other people's posts)

@pllee
Copy link

pllee commented May 1, 2013

I think I am having the same issue. I am using version 0.30.0 from npm. It looks like for
every include my append "head" get repeated.

layout.jade

doctype strict
html(xmlns="http://www.w3.org/1999/xhtml",xml:lang="en-US", lang="en-US")
  head
    block head
      script(src='/vendor/jquery.js')
      script(src='/vendor/caustic.js')
  body
      include includes/header
      include includes/header
      include includes/header
      include includes/header
      block content

login.jade

extends layout

append head
  script(src='/vendor/three.js')

login.html

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US" lang="en-US">
  <head>
    <script src="/vendor/jquery.js"></script>
    <script src="/vendor/caustic.js"></script>
    <script src="/vendor/three.js"></script>
    <script src="/vendor/three.js"></script>
    <script src="/vendor/three.js"></script>
    <script src="/vendor/three.js"></script>
    <script src="/vendor/three.js"></script>
  </head>
  <body>
  </body>
</html>

@ashchan
Copy link

ashchan commented May 2, 2013

Same issue here.

@cooolbasha
Copy link
Author

any updates on this

@natgithub
Copy link

I had the same "triple" block effect only when deploying to heroku (locally it was fine), and I was able to resolve it by specifying the version of jade to deploy to heroku in my package.json file:

"dependencies": {
"jade": "0.28.2"
}

@nick-ma
Copy link

nick-ma commented May 9, 2013

Same problem. 0.28.2 works fine but 0.30.0 not.

@noosxe
Copy link

noosxe commented May 9, 2013

Also having this issue of duplicated output for "block append" v0.29.0 works fine.

@ForbesLindesay
Copy link
Member

This is hopefully fixed by the latest version.

@thomas-riccardi
Copy link

It is not.
I tested with v0.35.0 and with today's master (bd6233b), and the multiple issues described here are still present, see #1261.

@ForbesLindesay
Copy link
Member

@triccardi-systran any chance you could submit a pull request with some failing unit tests?

@thomas-riccardi
Copy link

From #1261:

Issue 1 desn't return what I expect because block append also return its block value to its parent, like normal block.
I'd expect it would not return its value as it's an append operation: we only modify the value of a block that is rendered somewhere else.
The current behavior for block is however expected: it's both a "define a block that may be modified elsewhere", and "render the block value here" (and also "here is the default value for this block").
Keeping these behaviors for block append and block prepend makes no sens to me.

If we are OK for this point, I'm willing to write multiple unit tests to validate these behaviors.

For Issue 2 it seems the included block appends are handled before the block appends in the current .jade. I can write a unit test for that too, but I won't do it just for this point (too much overhead).

Issue 3 is in fact the combination of Issue 1 and Issue 2.

@ForbesLindesay
Copy link
Member

It does sound like both issue 1 and issue 2 are bugs. It's very difficult to see exactly what is going on from purely a post in an issue though. Writing a unit test will make it a lot clearer what you are doing, and will therefore make it easier to fix it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants