I have a jade variable declared like this:
BUTTONS = { more_blue: {caption: BUTTONS_CAPTIONS.more, style: BUTTONS_STYLES.blue}, more_red: {caption: BUTTONS_CAPTIONS.more, style: BUTTONS_STYLES.red}, see: {caption: BUTTONS_CAPTIONS.see, style: BUTTON_STYLE_PHOTOS}, see_photos: {caption: BUTTONS_CAPTIONS.see_photos, style: BUTTON_STYLE_PHOTOS}, program : {caption: BUTTONS_CAPTIONS.program, style: BUTTON_STYLE_PROGRAM}, see_program : {caption: BUTTONS_CAPTIONS.see_program, style: BUTTON_STYLE_PROGRAM} }
but I would like it to be more readable like this:
BUTTONS = { more_blue: {caption: BUTTONS_CAPTIONS.more, style: BUTTONS_STYLES.blue}
, more_red: {caption: BUTTONS_CAPTIONS.more, style: BUTTONS_STYLES.red}
, see: {caption: BUTTONS_CAPTIONS.see, style: BUTTON_STYLE_PHOTOS}
, see_photos: {caption: BUTTONS_CAPTIONS.see_photos, style: BUTTON_STYLE_PHOTOS}
, program : {caption: BUTTONS_CAPTIONS.program, style: BUTTON_STYLE_PROGRAM}
, see_program : {caption: BUTTONS_CAPTIONS.see_program, style: BUTTON_STYLE_PROGRAM}
}
but this code doesn't compile even if I add backslashes at the end of each line. Are there any workarounds?
Jade now supports multineline variables, as described in the docs:
Your question surprised me. I have made some tests in Jade:
This worked (as you said):
person = {name: 'Bill', age: 50}
This worked too:
- person = {name: 'Bill', age: 50}
This did not (Jade could not compile it:
This is a good workaround: