FIX: Registering emoji via plugin.rb was broken

This commit is contained in:
Robin Ward 2016-07-21 14:10:57 -04:00
parent d7ffbf9c97
commit c11f7bee99

View file

@ -264,6 +264,29 @@ JS
end
end
if emojis.present?
emoji_registrations = ""
emojis.each do |name, url|
emoji_registrations << "emoji.registerEmoji(#{name.inspect}, #{url.inspect});\n"
end
js << <<~JS
define("discourse/initializers/custom-emoji",
["pretty-text/emoji", "exports"],
function(emoji, __exports__) {
"use strict";
__exports__["default"] = {
name: "custom-emoji",
after: "inject-objects",
initialize: function(container) {
#{emoji_registrations}
}
};
});
JS
end
# Generate an IIFE for the JS
js = "(function(){#{js}})();" if js.present?