I have the haml code template as below:
%td= link_to "Enable", enable_product(@product)
%td= link_to 'Disable', disable_product(@product)
And it display like
Enable
Disable
But it display in two cell of the table. What I want to display is to put it into 1 cell only. Like
Enable/Disable Product
Apparently, I still want to get the hyperlink under Enable and Disable.
How I can do that in Haml?
Thank you!
The concatenation tip is all good.
Just for the record, here's another method, using HAML's whitespace removal:
%td
%span>
= link_to "Enable", "#"
\/
%span>
= link_to "Disable", "#"
The >
"eats" the whitespace around the span tags.
Why do we need the spans? Because HAML's whitespace removal only works on actual HAML tags, not on strings coming from Ruby.
As link_to produces a string, you can concatenate them:
%td= link_to("Enable", enable_product(@product))+'/'+link_to('Disable', disable_product(@product))
maybe you have to declare the result as html_safe:
%td= (link_to("Enable", enable_product(@product))+'/'+link_to('Disable', disable_product(@product))).html_safe
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With