Wednesday, January 12, 2011

Facebook FBML in HAML and RUBY

Thought i'd jot this down for others who may come across the same situation.
Here's how to get the Facebook FBML to render correctly in a Ruby on Rails application using HAML markup. Note this syntax is for Ruby 1.9.2 where the hash syntax uses {width: '178px'} in lieu of {:width => '178px'}. Both work, pick what works best for your situation.

Normal facebook FBML code:

<fb:login-button perms="<%= FB_PERMS %>" show-faces="true" width="178px"></fb:login-button>



Correct HAML / Ruby 1.9.2 code:

%fb:login-button(show-faces=true){perms: FB_PERMS, width:'178px'}