首页 > 解决方案 > tryhandlebarsjs 注册 Helper 函数

问题描述

我正在玩tryhandlebarsjs.com

我有以下功能:

export const cellHelper = {
    name: "cell",
    handler: (context) => {
        //...
        return template
    }
}

如果我按原样通过它,我会得到Error(s): SyntaxError: Unexpected token export. 将它传递给tryhandlebarsjs.com的正确语法是什么?

标签: javascripthandlebars.js

解决方案


像这样传递它:

Handlebars.registerHelper('cell', function(context) {
   //...
   return template
});

推荐阅读