转换前的工作ERB:
<table class="tabularData tabularData--tableInner">
<tbody>
<%= content_tag :tr do
concat content_tag(:td, t('consumer.labels.account_number'), width: "180")
concat content_tag(:td, consumer.account_number)
end if consumer.account_number %>
<%= content_tag :tr do
concat content_tag(:td, t('consumer.labels.paybyvouchers_id'))
concat content_tag(:td, consumer.paybyvouchers_id)
end if consumer.paybyvouchers_id %>
<%= content_tag :tr do
concat content_tag(:td, t('consumer.labels.created_on'), width: "180")
concat content_tag(:td, display_date(consumer.created_at)[:defaultFormat])
end %>
<%= content_tag :tr do
concat content_tag(:td, t('consumer.labels.date_of_birth'))
concat content_tag(:td, display_date(consumer.date_of_birth)[:defaultFormat])
end %>
<%= content_tag :tr do
concat content_tag(:td, t('consumer.labels.age'))
concat content_tag(:td, consumer.age.value)
end %>
<%= content_tag :tr do
concat content_tag(:td, t('consumer.labels.preferred_language'))
concat content_tag(:td, consumer.language.name)
end %>
<%= content_tag :tr do
concat content_tag(:td, t('consumer.labels.country_of_nationality'))
concat content_tag(:td, consumer.country_of_nationality.name)
end %>
<%= content_tag :tr do
content_tag(:td, t('consumer.labels.address')) +
content_tag(:td) do
concat consumer.address_line_1
if consumer.address_line_2.present?
concat tag(:br, nil, true)
concat consumer.address_line_2
end
concat tag(:br, nil, true)
concat consumer.postcode
concat tag(:br, nil, true)
concat consumer.city
if consumer.state.present?
concat tag(:br, nil, true)
concat consumer.state
end
concat tag(:br, nil, true)
concat consumer.country.name
end
end %>
<%= content_tag :tr do
concat content_tag(:td, t('consumer.labels.primary_phone_number'))
concat content_tag(:td, display_phone_number(consumer.primary_isd_code, consumer.primary_phone_number))
end %>
<%= content_tag :tr do
concat content_tag(:td, t('consumer.labels.secondary_phone_number'))
concat content_tag(:td, display_phone_number(consumer.secondary_isd_code, consumer.secondary_phone_number))
end if consumer.secondary_phone_number %>
</tbody>
</table>
&#13;
转换后不使用HAML:
错误:/Users/app/views/shared/_consumer_personal_details_table.html.haml:3:语法错误,意外的tIDENTIFIER,期待keyword_end ..._ number&#39;),宽度:&#34; 180&#34 ;)concat content_tag(:td,consumer.ac ...... ... ^
%table.tabularData.tabularData--tableInner
%tbody
= content_tag :tr do |
concat content_tag(:td, t('consumer.labels.account_number'), width: "180") |
concat content_tag(:td, consumer.account_number) |
end if consumer.account_number |
= content_tag :tr do |
concat content_tag(:td, t('consumer.labels.paybyvouchers_id')) |
concat content_tag(:td, consumer.paybyvouchers_id) |
end if consumer.paybyvouchers_id |
= content_tag :tr do |
concat content_tag(:td, t('consumer.labels.created_on'), width: "180") |
concat content_tag(:td, display_date(consumer.created_at)[:defaultFormat]) |
end |
= content_tag :tr do |
concat content_tag(:td, t('consumer.labels.date_of_birth')) |
concat content_tag(:td, display_date(consumer.date_of_birth)[:defaultFormat]) |
end |
= content_tag :tr do |
concat content_tag(:td, t('consumer.labels.age')) |
concat content_tag(:td, consumer.age.value) |
end |
= content_tag :tr do |
concat content_tag(:td, t('consumer.labels.preferred_language')) |
concat content_tag(:td, consumer.language.name) |
end |
= content_tag :tr do |
concat content_tag(:td, t('consumer.labels.country_of_nationality')) |
concat content_tag(:td, consumer.country_of_nationality.name) |
end |
= content_tag :tr do |
content_tag(:td, t('consumer.labels.address')) + |
content_tag(:td) do |
concat consumer.address_line_1 |
if consumer.address_line_2.present? |
concat tag(:br, nil, true) |
concat consumer.address_line_2 |
end |
concat tag(:br, nil, true) |
concat consumer.postcode |
concat tag(:br, nil, true) |
concat consumer.city |
if consumer.state.present? |
concat tag(:br, nil, true) |
concat consumer.state |
end |
concat tag(:br, nil, true) |
concat consumer.country.name |
end |
end |
= content_tag :tr do |
concat content_tag(:td, t('consumer.labels.primary_phone_number')) |
concat content_tag(:td, display_phone_number(consumer.primary_isd_code, consumer.primary_phone_number)) |
end |
= content_tag :tr do |
concat content_tag(:td, t('consumer.labels.secondary_phone_number')) |
concat content_tag(:td, display_phone_number(consumer.secondary_isd_code, consumer.secondary_phone_number)) |
end if consumer.secondary_phone_number
&#13;
答案 0 :(得分:1)
您没有使用HAML语法。
而不是
= content_tag :tr do
concat content_tag(:td, t('consumer.labels.secondary_phone_number'))
concat content_tag(:td, display_phone_number(consumer.secondary_isd_code, consumer.secondary_phone_number)) |
end if consumer.secondary_phone_number
写
- if consumer.secondary_phone_number
%tr
%td= t('consumer.labels.secondary_phone_number'))
%td= display_phone_number(consumer.secondary_isd_code, consumer.secondary_phone_number))