johno / ember-cli-gravatar

An Ember component for gravatar image tags
MIT License
45 stars 24 forks source link

Allow checking if gravatar exists #49

Closed andyo729 closed 7 years ago

andyo729 commented 7 years ago

Trying to think of the best way to do this. But in general my idea would be to keep the inline component as-is and then add an additional block component that yields image and exists.

Would look something like this:

{{#gravatar-image email='test@github.com' as |g|}}
  {{#if g.exists}}
    {{g.image}}
  {{else}}
    Image not found!
  {{/if}}
{{/gravatar-image}}
andyo729 commented 7 years ago

I ended up adding a new component has-gravatar that leaves that original component alone and just does a check with a yield.

andyo729 commented 7 years ago

If you think this is something that looks good, I can take the time to write tests and everything for it.

johno commented 7 years ago

This is great! Would gladly merge this in if you could toss in some tests and documentation. Thank you!

andyo729 commented 7 years ago

@johnotander I moved the ajax call into a service and ran some unit tests over it. Since components aren't very good with async, I wasn't able to do integration tests. Let me know if you need anything else.

Thanks!

johno commented 7 years ago

Radical! Thanks!

ghost commented 7 years ago

I'm attaching small Pull Request. Please have a look. I tested with our app, worked flawlessly.

https://github.com/johnotander/ember-cli-gravatar/pull/55