Suitescript 1.0 和 handlebars js

Suitescript 1.0 & handlebars js

我开始审查使用 suitescript 1.0

从 suitelet 中处理一些 HTML 模板的一些要求

我无法从 netsuite 中找到有关 handlebars JS 的任何信息,但我很好奇是否有任何要求来配置执行服务器端生成的套件,因为我更愿意使用它与使用客户端实现相比

如果有人可以分享任何有用的信息,说明如何让小套房准备好使用车把,我们将不胜感激

下面是我在其中使用车把的 Suitelet 之一的示例。您可以通过创建一个表单对象和一个 html 字段来像设置任何其他套件一样设置 suitelet 来保存呈现的车把模板。

        var screenTitle = 'Form Title';
        var form = nlapiCreateForm(screenTitle);
        var pageTemplate = nlapiLoadFile('SuiteBundles/Bundle '+sitBundleId+'/src/sit_html_templates/template.html').getValue();
        var hbTemplate = Handlebars.compile(pageTemplate);
        Handlebars.registerHelper('if_eq',function(a,b,opts) { if(a == b) { return opts.fn(this); } else { return opts.inverse(this); } });
        Handlebars.registerHelper('json', function(context) { return JSON.stringify(context); });
        var data = {
                "account_id":nlapiGetContext().getCompany(),
                "bundle_id":sitBundleId,
                "other_data":{}
        };
        var htmlValue = hbTemplate(data);
        var templateField = form.addField('template_section','inlinehtml','',null,'main_group');
        templateField.setDefaultValue(htmlValue);
        response.writePage(form);

这就是基础知识。当然,必须将 Handlebar 库添加到 NetSuite Suitelet 记录上的库子列表中。