kofhearts
kofhearts

Reputation: 3774

How to put two links in one line in HAML?

I want to put two links next to each other in the same line with a space in between.

The following syntax is giving error. I appreciate any help! Thanks!

  %p= link_to(h.title, h) link_to("Delete", homework_path(h), method: :delete, data: {confirm: "Are you sure?"})

Also how can i make a text and then link appear in the same line. I tried

%p Title: =link_to(h.title, h)

Upvotes: 0

Views: 788

Answers (1)

Wheeyls
Wheeyls

Reputation: 1012

Put your links on seperate lines, nested inside the %p:

%p
  = link_to(h.title, h)
  = link_to("Delete", homework_path(h), method: :delete, data: {confirm: "Are you sure?"})

You can use the succeed helper to add white space after the first one:

%p
  = succeed ' ' do
    = link_to(h.title, h)
  = link_to("Delete", homework_path(h), method: :delete, data: {confirm: "Are you sure?"})

Upvotes: 2

Related Questions