I want to use Jade to decide whether read some code.

I seperate my jade file in a index file, and then include other needed file.

index.jade

body
    include header
    block main
    include footer

I will extend the block main in other jade file.

My prblem is I want to reuse this index file.
However, in some case, I hope it will not include the footer.
Thus, I think I can use if..else to do that.

I want to ask does the if..else help me to judge the extends file name?

For example:

if it is not no_footer.jade
    include footer

I am not sure whether jade has this function.

If the jade can't help me do that, very sorry for this stupid question.

But I really need your help! thank you!

有帮助吗?

解决方案

I want to ask does the if..else help me to judge the extends file name?

No, you cannot do this withJade.

But you can solve the problem by including a file where you wrap the content of it into a block and in your jade file which should not show the content you can overwrite the block with no content

footer.jade

block footer
  span copyright 2014

page_without_footer.jade

extends index
block main
  p lorem ipsum

//- overwrite the footer with nothing / delete the block
block footer
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top