Using HAML with FBML

Just a quick post here, hopefully I'll get around to making some more posts. I've been busy getting my current job's project http://openstudy.com/ up in open mode. Still very beta, but very cool.

 Anyway, we needed to use FBML with HAML at some point, and it turns out that's super easy. Here's how to render a login-button from FBML in HAML:

 
  %fb:login-button{:size => 'medium', :length => 'long', |           :onlogin => 'facebookUserLoggedIn();'} |

 Remember that the pipe symbol (|) is used for line continuations in HAML. I like to keep my lines at 80 characters or less. Other than that, the rest is the usual HAML syntax. Using namespaced syntax is perfectly kosher in HAML, so you don't need to do any extra work.

 Hope this comes in useful to some people!
7 responses
Yes, it did come in useful. Thanks! (Just thought I'll leave a note)
Good to hear. I appreciate your letting me know!
It seems you have used haml for facebook apps, i want you to please describe me what extension should i put in for a view file to be understood by Facebook rendering engine, that it is haml file.

Like i do as some_view.fbml.erb in simple situation, but with HAML what it could turn out to be?

.fbml.haml should do the trick, but I don't know that you need that. We always used .html.haml. Most of the FBML stuff happens in Javascript anyway, we just added the fbml xmlns and went with it.
3 visitors upvoted this post.