Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

.each do else statement in HTML Slim

I have an HTML Slim document and I 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 am not at all familiar with HTML Slim and I have very little experience with Ruby. Thanks in advance!

like image 857
user3101431 Avatar asked Feb 22 '14 03:02

user3101431


1 Answers

What about something like

- if @books.present?
  - @books.each do |rep|
    .row
      ... draw the book
- else
  .row No Books Here
like image 125
mr rogers Avatar answered Oct 01 '22 02:10

mr rogers