.each do else in HTML Slim

I have an HTML Slim document and would like to know how to put an else statement if no results are found. Here is my current code:

- @books.each do |rep|
  .row
    .large-12.columns
      .bookinfo
        .name= book.name
        = book.title_name
        br
        = mail_to author.email, author.email
        br
        a.phonenumber href="tel:#{ author.phone }"= author.phone

Sorry, I'm not familiar with HTML Slim at all, and I have very little experience with Ruby. Thanks in advance!

+4
source share
1 answer

Sort of

- if @books.present?
  - @books.each do |rep|
    .row
      ... draw the book
- else
  .row No Books Here
+11
source

Source: https://habr.com/ru/post/1528228/


All Articles