Search code examples
ruby-on-railsrubymine

Rubymine warns header partial HTML with "element table is not close"


I have view files like these:

comments/_comment.html.erb

<tr>
  <td><%= comment.author %></td>
  <td><%= comment.text %></td>
</tr>

comments/_table_header.html.erb

<table>
  <thead>
  <tr>
    <td>Author</td>
    <td>Text</td>
  </tr>
  </thead>
  <tbody>

comments/_table_footer.html.erb

  </tbody>
</table>

Then I got warning "element table is not close" by RubyMine.

Is there a better way to write table this? If there is not, is there a way to suppress the warning only when the file name includes _header or _footer?

I want keep active this warning itself for other files.


Solution

  • Use a _table.html.erb partial and don't split it up into header and footer.

    comments/_table.html.erb

    <table>
      <thead>
      <tr>
        <td>Author</td>
        <td>Text</td>
      </tr>
      </thead>
      <tbody>
        <%= render @comments %> <!-- Rails magic here! -->
      </tbody>
    </table>
    

    comments/_comment.html.erb

    <tr>
      <td><%= comment.author %></td>
      <td><%= comment.text %></td>
    </tr>