ruby on rails - HAML: Got "elsif" with no preceding "if" -


i need construction in haml code:

- if @organisation.type == 'company' %p   %strong number of employees:   = @organisation.number_of_employees - elsif @organisation.type == 'educationalinstitution' %p   %strong number of students   = @organisation.number_of_students 

but syntax error: got "elsif" no preceding "if" how must update code solve error?

your indentation looks might issue

- if @organisation.type == 'company'   %p     %strong number of employees:     = @organisation.number_of_employees - elsif @organisation.type == 'educationalinstitution'   %p     %strong number of students     = @organisation.number_of_students 

bonus indenting quirk

the if/else statement fail if commenting not adhere correct indentation.

e.g.

- if @organisation.type == 'company'   %p     %strong number of employees:     = @organisation.number_of_employees  -# institutional case - elsif @organisation.type == 'educationalinstitution'   %p     %strong number of students     = @organisation.number_of_students 

will fail.

- if @organisation.type == 'company'   %p     %strong number of employees:     = @organisation.number_of_employees  - elsif @organisation.type == 'educationalinstitution'   -# institutional case   %p     %strong number of students     = @organisation.number_of_students 

will correct.


Comments

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -