HAML:得到 "elsif",前面没有 "if"
HAML: Got "elsif" with no preceding "if"
我的 HAML 代码中需要这个结构:
- 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
但我收到语法错误:得到 "elsif",前面没有 "if"
我必须如何更新我的代码才能解决错误?
您的缩进看起来可能是问题所在
- 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
额外的缩进怪癖
if/else 如果注释不符合正确的缩进,语句将失败。
例如
- 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
会失败。其中
- 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
意志是正确的。
我的 HAML 代码中需要这个结构:
- 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
但我收到语法错误:得到 "elsif",前面没有 "if" 我必须如何更新我的代码才能解决错误?
您的缩进看起来可能是问题所在
- 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
额外的缩进怪癖
if/else 如果注释不符合正确的缩进,语句将失败。
例如
- 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
会失败。其中
- 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
意志是正确的。