您如何将这种多行失败转换为 HAML?
我无法完全理解这一点。
原始:
<%=
Shasta::CSV.generate do |csv|
csv << ["Customer", "Job Name", "Payment Date", "Amount", "Notes"]
for payment in @payments
csv << [
payment.customer.name,
payment.jobs.map(&:name).join(" "),
I18n.l(payment.created_at, :format => :short_date),
number_to_currency(payment.amount),
payment.notes
]
end
end.html_safe
%>
HTML2HAML 将其转换为此,但失败
= Shasta::CSV.generate do |csv| |
csv << ["Customer", "Job Name", "Payment Date", "Amount", "Notes"] |
for payment in @payments |
csv << [ |
payment.customer.name, |
payment.jobs.map(&:name).join(" "), |
I18n.l(payment.created_at, :format => :short_date), |
number_to_currency(payment.amount), |
payment.notes |
] |
end |
end.html_safe |
I can't quite wrap my mind around this.
Original:
<%=
Shasta::CSV.generate do |csv|
csv << ["Customer", "Job Name", "Payment Date", "Amount", "Notes"]
for payment in @payments
csv << [
payment.customer.name,
payment.jobs.map(&:name).join(" "),
I18n.l(payment.created_at, :format => :short_date),
number_to_currency(payment.amount),
payment.notes
]
end
end.html_safe
%>
HTML2HAML Converted it to this, but it fails
= Shasta::CSV.generate do |csv| |
csv << ["Customer", "Job Name", "Payment Date", "Amount", "Notes"] |
for payment in @payments |
csv << [ |
payment.customer.name, |
payment.jobs.map(&:name).join(" "), |
I18n.l(payment.created_at, :format => :short_date), |
number_to_currency(payment.amount), |
payment.notes |
] |
end |
end.html_safe |
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这并不完全是您问题的答案,但编写多行 haml 语句很痛苦,这就是为什么您应该将其移至助手中。
= some_descriptive_method_name @ payments
This isn't exactly the answer to your question, but it's a pain to write multiple line haml statements which is why you should probably move it into a helper.
= some_descriptive_method_name @payments