如何在haml代码中删除一行table?
How to delete a row of table in haml code?
正在编写 haml 代码。如果满足条件,我想删除一行或干脆将其从 table 中消失。有什么办法可以完成这个任务吗?
- if post_name.present?
%td= 'Present'
- elsif post_name.blank?
%td= 'none'
- else
%td= ''
这只是一个例子。如果 post_name.blank? 是 true 那么我想删除或消失该行。
干脆不要渲染它。您可能有一个 %tr
条目,对吗?我想你可以删除它...
- @rows.each do |row|
- if row.post_name.present?
%tr
%td = 'Present'
(any other columns you want included)
为了使该行消失,您必须在 tr
而不是 td
上添加条件。
- if post_name.present?
%tr
%td= 'Present'
%td= 'Some other columns'
正在编写 haml 代码。如果满足条件,我想删除一行或干脆将其从 table 中消失。有什么办法可以完成这个任务吗?
- if post_name.present?
%td= 'Present'
- elsif post_name.blank?
%td= 'none'
- else
%td= ''
这只是一个例子。如果 post_name.blank? 是 true 那么我想删除或消失该行。
干脆不要渲染它。您可能有一个 %tr
条目,对吗?我想你可以删除它...
- @rows.each do |row|
- if row.post_name.present?
%tr
%td = 'Present'
(any other columns you want included)
为了使该行消失,您必须在 tr
而不是 td
上添加条件。
- if post_name.present?
%tr
%td= 'Present'
%td= 'Some other columns'