mirror of
https://github.com/flarum/framework.git
synced 2025-01-09 20:44:05 +08:00
23 lines
705 B
JavaScript
23 lines
705 B
JavaScript
import Ember from 'ember';
|
|
|
|
export default Ember.Handlebars.makeBoundHelper(function(user, options) {
|
|
var attributes = 'class="avatar '+(options.hash.class || '')+'"';
|
|
var content = '';
|
|
|
|
if (user) {
|
|
var username = user.get('username') || '?';
|
|
attributes += ' title="'+Ember.Handlebars.Utils.escapeExpression(username)+'"';
|
|
|
|
var avatarUrl = user.get('avatarUrl');
|
|
if (avatarUrl) {
|
|
return new Ember.Handlebars.SafeString('<img src="'+avatarUrl+'" '+attributes+'>');
|
|
}
|
|
|
|
content = username.charAt(0).toUpperCase();
|
|
attributes += ' style="background:'+user.get('color')+'"';
|
|
}
|
|
|
|
return new Ember.Handlebars.SafeString('<span '+attributes+'>'+content+'</span>');
|
|
});
|
|
|