在requirejs中需要胡须模板

在requirejs中需要胡须模板,requirejs,mustache,Requirejs,Mustache,我正在使用requirejs中的胡子模板和文本插件 define(['text!templates/popups.html', 'mustache'], function (Mustache,popups) { var mustacheTmpl = Mustache.render(popups, {jData:jsonObj}); } 我想根据如下条件调用模块中的mustache模板 define(['mustache'], function (Mustache) { if ($(

我正在使用requirejs中的胡子模板和文本插件

define(['text!templates/popups.html', 'mustache'], function (Mustache,popups) {

var mustacheTmpl = Mustache.render(popups, {jData:jsonObj});

}
我想根据如下条件调用模块中的mustache模板

define(['mustache'], function (Mustache) {
    if ($('.element').length) {
        require(['text!templates/mustachetemplate'],
            function(mustachetemplate) {
                var mustacheTmpl = Mustache.render(mustachetemplate, {jData:jsonObj});
        })
    }
}

这怎么可能呢?

我发现它实际上是按照我的方式工作的。失败的原因是因为其他代码被阻塞。

是的,这完全有可能。第二个代码段中有什么不起作用?