我正在使用grunt-contrib-jasmine
和grunt-template-jasmine-requirejs
来生成模板。它在Node v0.12.14上工作正常,但是当我升级到Node v4.5.0时,我的specrunner文件输出格式不正确。它在输出和HTML中都有大量的JavaScript。示例块:
function (obj) {
obj || (obj = {});
var __t, __p = '', __j = Array.prototype.join;
function print() { __p += __j.call(arguments, '') }
with (obj) {
__p += '<!doctype html>\n<html>\n<head>\n <meta charset="utf-8">\n <title>Jasmine Spec Runner</title>\n\n ';
css.forEach(function(style){ ;
__p += '\n <link rel="stylesheet" type="text/css" href="' +
((__t = ( style )) == null ? '' : __t) +
'">\n ';
}) ;
__p += '\n\n ';
with (scripts) { ;
__p += '\n ';
[].concat(vendor).forEach(function(script){ ;
__p += '\n <script src="' +
((__t = ( script )) == null ? '' : __t) +
'"></script>\n ';
这是&#39;茉莉花&#39;我的Gruntfile中的部分:
jasmine: {
test: {
options: {
vendor: ["src/libs/jquery.js"],
display: "short",
summary: true,
specs: ['test/test.js'],
styles: ['src/css/main.css'],
template: require('grunt-template-jasmine-requirejs'),
templateOptions: {
requireConfig: {
baseUrl: 'src/',
paths: {
"test": "../test",
"jquery-1.9": "jquery-1.9.1"
}
}
}
}
}
}
有一些&#39; templateOptions&#39;为&#39; grunt-template-jasmine-requirejs&#39;改变了我不知道的?以下是我使用的版本:
grunt-template-jasmine-requirejs 0.2.3
grunt-contrib-requirejs 1.0.0
grunt-contrib-jasmine 1.0.3
答案 0 :(得分:0)
自更新到Grunt v1.0.1以来,问题在于不再维护的包grunt-template-jasmine-requirejs
。它应以不同方式处理模板:grunt.util._.template(source, context)
应为grunt.util._.template(source)(context)
。此外,它使用的Lodash版本与我们的Lodash版本相撞。
这里有一个解决这些问题的分支:https://github.com/radum/grunt-template-jasmine-requirejs/tree/7ca7ad28b1bbb7a940de7a01710f62c5b0eb6a65
但是,此fork仍然使用现已弃用的grunt.util._
,因此将来可能需要重新寻址。