Skip to content

Commit

Permalink
Update gravatar example in README
Browse files Browse the repository at this point in the history
  • Loading branch information
defunkt committed Oct 8, 2010
1 parent 49faf79 commit 0c240e8
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions README.md
Expand Up @@ -208,9 +208,9 @@ you want to use in all your views? No problem.
This is just Ruby, after all.

module ViewHelpers
def gravatar(email, size = 30)
gravatar_id = Digest::MD5.hexdigest(email.to_s.strip.downcase)
gravatar_for_id(gravatar_id, size)
def gravatar
gravatar_id = Digest::MD5.hexdigest(self[:email].to_s.strip.downcase)
gravatar_for_id(gravatar_id)
end

def gravatar_for_id(gid, size = 30)
Expand Down Expand Up @@ -242,6 +242,10 @@ Then just include it:
def in_ca
true
end

def users
User.all
end
end

Great, but what about that `@ssl` ivar in `gravatar_host`? There are
Expand All @@ -265,7 +269,13 @@ Now:

Simple.new(request.ssl?).render

Convoluted but you get the idea.
Finally, our template might look like this:

<ul>
{{# users}}
<li><img src="{{ gravatar }}"> {{ login }}</li>
{{/ users}}
</ul>


Sinatra
Expand Down

0 comments on commit 0c240e8

Please sign in to comment.