help with using helpers inside my theme

Moved NodeBB Development
  • I managed to make some changes on my template from the client side, but am trying to do the same thing on the server side. I am trying to create a helper. but somehow It doesn't work. here what I have done :
    first I added the hook on plugin. json :
    { "hook": "filter:topics.get", "method": "clAppendTitle" }
    then in library.js I added this code :
    var Benchpress = require.main.require('benchpressjs');

    library.clAppendTitle = function (params, callback) {
    Benchpress.registerHelper('clAppendTitle', function () {
    console.log("inside my filter");

    I am trying to solve this issue for some time now. please someone help ! I am unable to figure out how to create and use helpers. I am using the last version of nodebb.

  • So, you need to provide the helpers both server-side and client-side. To do this, you first want to create a module that will work in both contexts:

    // helpers.js
    (function (factory) {
      if (typeof module === 'object' && module.exports) {
      } else {
        require(['benchpress'], factory);
    })(function (Benchpress) {

    Then, you want to require this module in your plugin server-side:

    // library file
    require('./helpers'); // doesn't need to be inside the init hook

    Then you want to make sure it's included client-side by including it under "scripts" in your plugin.json:

      "scripts": [
  • @PitaJ thank you so much!

  • @PitaJ it doesn't seem to work anymore. Any update ?

  • @Yoann-Aubry-0 you're going to need to be more specific. Decide whether you want to have this discussion in your own topic, or in this one, and only redpond in one of those places.

  • @PitaJ I have created a specific topic. Is there a working example of helper implementation ? I have see nothing on GitHub and other modules/themes.

Suggested Topics