passing a string is deprecated

  • Anime Lovers

    I am totally get confused by the output message:

    winston.warn('[widgets.render] passing a string is deprecated!, filter:widget.render:' + widget.widget + '. Please set hookData.html in your plugin.');

    There isn't any full example showing the correct way to code.
    So I turn the forum for help, is there any people who could give me an example showing how to let the warning not showing?

  • Community Rep

    Oh! I'm glad they finally made that change. This means you pass back the widget html in an object.

    // filter:widget.render:widget
    exports.renderWidget = function (data, next) {
       var html = "<b>Awesome Widget</b>";
       next(null, {html: html});

  • Admin

    The code @yariplus posted will get rid of the warning. If you somehow have 2 different plugins listening to the same widget hook you should set the html object on the data itself like so.

    // filter:widget.render:widget
    exports.renderWidget = function (data, next) {
       data.html = "<b>Awesome Widget</b>";
       next(null, data);


| |