hello im using jade with nodejs and express to make webpages, in this case i want to use the if statement to create a body with differents styles...
here is the code
-if(image && image.length)
body(style="background-image:url(#{image})")
-if(color && color.length)
body(style="background-color:#{color}")
h2 hello world
if background exists use background image
if color exists use a background-color
but the problem is when image exists the hello world or all the code indented on body doesnt work, if i put color up image when color exists the rest of the code is empty...
how can i solve this
EDIT 2:
im patching this problem using include in both statements
-if(image && image.length)
body(style="background-image:url(#{image})")
include restofcode
-if(color && color.length)
body(style="background-color:#{color}")
include restofcode
restofcode.jade
h2 hello world
and all works fine
Try this instead of not being able to indent it properly:
- var myStyle = ''
- if(image && image.length)
- myStyle += "background-image:url(" + image + ");";
- if(color && color.length)
- myStyle += "background-color:" + color + ";";
body(style=myStyle)
h2 Hello World