Lyudmil
Lyudmil

Reputation: 1163

Flexible image buttons in HAML

I'm working on a Rails application and using HAML for the views. I would like to use the "sliding doors" technique to create pretty buttons, which means I need to get HAML to generate something similar to the following HTML:

<a href="#" class="button"><span class="button">Button text</span></a>

I haven't been able to figure out how to do that from the HAML reference or Google. Could you help please? Many thanks in advance.

EDIT: To clarify, I need to use the link_to helper because I'm linking to a resource. When I try to pass a block into the method, I get an error: undefined method 'stringify keys'

Upvotes: 1

Views: 1574

Answers (2)

robzolkos
robzolkos

Reputation: 2266

Try

 = link_to invitation_path(invitation), :method=>:put, :class=>"button" do
   %span(class="button")
     Accept

Upvotes: 4

aNoble
aNoble

Reputation: 7072

This should be as simple as:

%a(href="#" class="button")
  %span(class="button") Button text

Or if you especially want it on one line without any whitespace you can do:

%a(href="#" class="button")<
  %span(class="button") Button text

Upvotes: 1

Related Questions