Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use md5.js within a compontent?

I just started working with Ember-CLI 0.0.36 and I'm stuck with the Gravatar example code from the Ember.js homepage.

I did

> bower install --save JavaScript-MD5
> ember generate component gravatar-image

Brocfile.js

[...]
app.import('vendor/JavaScript-MD5/js/md5.js');
[...]

app/components/gravatar-image.js

import Ember from 'ember';

export default Ember.Component.extend({
  size: 200,
  email: '',

  gravatarUrl: function() {
    var email = this.get('email'),
        size = this.get('size');

    return 'http://www.gravatar.com/avatar/' + md5(email) + '?s=' + size;
  }.property('email', 'size')
});

After starting ember server I'll get the following error message:

xyz/components/gravatar-image.js: line 11, col 48, 'md5' is not defined.
1 error

How can I tell the component to use JavaScript-MD5?

like image 841
wintermeyer Avatar asked Dec 14 '22 21:12

wintermeyer


1 Answers

To get this to work I used:

bower install blueimp-md5 --save-dev

and added import in Brocfile.js

app.import('bower_components/blueimp-md5/js/md5.js');

then add "md5" to predef array as mentioned by Oliver to suppress md5 warning.

like image 173
David Douglas Avatar answered Dec 25 '22 20:12

David Douglas