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

java - WARN : org.springframework.web.servlet.PageNotFound - No mapping found for HTTP request with URI [/board/] in DispatcherServlet with name 'appServlet' -

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

android - How to create dynamically Fragment pager adapter -