I am generating an email with dynamic content from a Haml template which parses info from an array.
Basically, the Haml receives an array filled with several hashes. In the code I have a block which looks like this:
%table
=arrayname.each do |object|
%tr
%td= object.name
%td= object.link
Whenever the email is sent the entire object arrayname
is included at the bottom of the HTML. This causes [#,#]
(more # when there are more objects) to show up at the top of the block. There is no way to manipulate this piece of text with CSS, else I would've just hidden it.
[#<Release @id=181 @title="test" @amurl="test.com" @iturl="test.com" @cover="test.com" @date="2012-03-28" @artist_name="Test">, #<Release @id=182 @title="test" @amurl="test.com" @iturl="test.com" @cover="" @date="2012-03-31" @artist_name="Test">]
The line is identical to the results shown when executing the code in IRB.
Can anyone tell me how to prevent this from happening?
With Haml, you don't need to use an =
for arrayname.each
because that's Ruby code you want run, but not displayed. To just run code, use a hyphen.
Instead, this should work:
%table
- arrayname.each do |object|
%tr
%td= object.name
%td= object.link
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