More minor little details tonight. First up, links to Amazon.com cookbooks in Haml:
%divThat produces slightly less than optimal display:
Find cookbooks from
%a{:href => "http://www.amazon.com/exec/obidos/redirect-home/#{AMAZON_ASSOCIATE_ID}"}><
Amazon.com
\:
Sigh. Haml is awesome for some things, but messing about with whitespace is not one of them. I want to remove whitespace from after the link to Amazon.com (so that the colon is immediately after the link). There should be whitespace after the text "Find cookbooks from" and the link. There also should be no whitespace inside the link.
Haml uses a trailing
>
to remove whitespace around tags and a trailing <
to remove whitespace inside the tag. There is a mnemonic to go with them, but I always have to look up which is which.At any rate, I end up with this Haml to do the trick:
%divLike I said, Haml does not excel when dealing with whitespace.
Find cookbooks from
=" "
%a{:href => "http://www.amazon.com/exec/obidos/redirect-home/#{AMAZON_ASSOCIATE_ID}"}><
Amazon.com
\:
To link to the actual cookbook searches, I create a helper with my Amazon referral ID embedded in it. Using that helper:
%divThat gets the search links working as desired:
Find cookbooks from
=" "
%a{:href => "http://www.amazon.com/exec/obidos/redirect-home/#{AMAZON_ASSOCIATE_ID}"}><
Amazon.com
\:
=" "
= @recipe['tag_names'].map{|tag| amazon_cookbook(tag)}.join(", ")
In addition to mucking with whitespace, I also get Google Ads placed at the bottom of the page.
That should just about do it for the minor cleanup. Tomorrow, I may do a little benchmarking and possibly explore implementing some caching on the site.
No comments:
Post a Comment