lucckystar lucckystar - 5 months ago 37
Node.js Question

500 Error:expected "indent", but got "newline"

ration_enum={' ':' ','定性':'定性','定量':'定量'}
for val, key in ration_enum
if modi_type=='edit'&&key==common_index.ration
option(value='#{key}', selected) #{val}
else
option(value='#{key}') #{val}


expected "indent", but got "newline"

Answer

Guessing this is a Jade template...

Jade follows the Python rule where whitespace matters, so you have to indent your code properly:

ration_enum={' ':' ','定性':'定性','定量':'定量'}
for val, key in ration_enum
    if medi_type == 'edit' && key == common_index.ration
        option(value='#{key}', selected) #{val}
    else
        option(value='#{key}') #{val}

Jade has flexible indentation in that you can choose whether to use tabs or spaces, as well as how many spaces. But, you have to be consistent in your choice throughout the template.