我有一个像这样声明的 jade 变量:
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} }
但我希望它像这样更具可读性:
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}
}
但即使我在每行末尾添加反斜杠,此代码也无法编译。有什么解决方法吗?
最佳答案
Jade 现在支持多线变量,如 in the docs 所述:
-
list = ["Uno", "Dos", "Tres",
"Cuatro", "Cinco", "Seis"]
each item in list
li= item
关于coding-style - Jade : declare a variable over multiple lines,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20419312/