我正在开发Laravel 5中已建好的系统。对于html,以前的开发人员已经使用了Backbone,但他已经使用了一些任务管理器。布局中只有两个JS文件。在一个文件中,他将所有基本需要的js文件和主干的所有JS文件拼接起来。他将这个文件命名为admin.js
。他使用了另一个文件,并将所有html模板用作预编译的句柄模板,并将其命名为admin_template.js
。他只在系统中使用这两个js文件。我有服务器代码的访问权限,但是没有可以指示他使用哪个构建系统的文件。服务器上没有package.json
。我想他会在他的本地使用这些东西,并且从不将这些东西推送到任何存储库或服务器。Grunt Handlebar预编译器模板
通过挖深,我已经知道他已经使用Grunt
。我已经管理生成admin.js
文件,就像他已经生成。对于他使用的模板JST
。我已搜索并找到一个grunt-contrib-handlebars。我已经设法生成模板文件,但它不与现有文件百分百匹配。例如,下面是现有的文件
this["JST"] = this["JST"] || {};
this["JST"]["admin/Modules/Base/Templates/InModalMessageTemplate.html"] = Handlebars.template(function (Handlebars,depth0,helpers,partials,data) {
this.compilerInfo = [4,'>= 1.0.0'];
helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
var buffer = "", stack1, helper, options, functionType="function", escapeExpression=this.escapeExpression, self=this, helperMissing=helpers.helperMissing;
function program1(depth0,data) {
var buffer = "", stack1, helper;
buffer += "\n<div id=\"inModalMessageWrap\" class=\"bs-callout bs-callout-danger ";
if (helper = helpers.type) { stack1 = helper.call(depth0, {hash:{},data:data}); }
else { helper = (depth0 && depth0.type); stack1 = typeof helper === functionType ? helper.call(depth0, {hash:{},data:data}) : helper; }
buffer += escapeExpression(stack1)
+ "\">\n";
return buffer;
}
的内容和换同款,检查我的文件
this["JST"] = this["JST"] || {};
this["JST"]["./public/assets/js/admin/Modules/Base/Templates/InModalMessageTemplate.html"] = Handlebars.template({"1":function(container,depth0,helpers,partials,data) {
var helper;
return "<div id=\"inModalMessageWrap\" class=\"bs-callout bs-callout-danger "
+ container.escapeExpression(((helper = (helper = helpers.type || (depth0 != null ? depth0.type : depth0)) != null ? helper : helpers.helperMissing),(typeof helper === "function" ? helper.call(depth0 != null ? depth0 : (container.nullContext || {}),{"name":"type","hash":{},"data":data}) : helper)))
+ "\">\n";
},"3":function(container,depth0,helpers,partials,data) {
var helper;
return "<div id=\"inModalMessageWrap\" class=\"bs-callout bs-callout-success "
+ container.escapeExpression(((helper = (helper = helpers.type || (depth0 != null ? depth0.type : depth0)) != null ? helper : helpers.helperMissing),(typeof helper === "function" ? helper.call(depth0 != null ? depth0 : (container.nullContext || {}),{"name":"type","hash":{},"data":data}) : helper)))
+ "\">\n";
}
检查前1有一些function program1(depth0,data) {
但在我产生1它不是。在以往的1中,我们有compilerInfo像this.compilerInfo = [4,'>= 1.0.0'];
和我产生1它缺少一些地方,它在某些地方它就像{"compiler":[7,">= 4.0.0"]
当我试图用我生成的文件运行项目,它说
`TypeError: templateSpec.call is not a function`
我搜索了这个错误,它是关于车把版本问题。我已经安装了上述版本,但这个错误不会在任何地方发生。这是我的gruntfile看起来像
module.exports = function(grunt) {
var libFiles = [
'./public/assets/js/admin/Modules/**/*.js'
];
// Project configuration.
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
concat: {
options: {
stripBanners: true,
banner: '/*! Compiled on: <%= grunt.template.today("mm-dd-yyyy") %> */' + '\n\n',
separator: "\n",
process: function (src, filepath) {
return '// Source: '+filepath+'\n\n' + src+'\n'
}
},
dist: {
src: libFiles,
dest: './public/assets/js/compiled/admin.js',
},
},
handlebars: {
compile: {
options: {
namespace: 'JST'
},
files: {
'./public/assets/js/compiled/my_template.js': ['./public/assets/js/admin/Modules/**/*.html']
}
}
}
});
// Load the plugin that provides the "uglify" task.
grunt.loadNpmTasks('grunt-contrib-concat');
grunt.loadNpmTasks('grunt-contrib-handlebars');
// Default task(s).
grunt.registerTask('default', ['concat', 'handlebars']);
};
任何机构可以让我知道我怎么能解决这个问题,才能够产生精确的文件已经存在预编译车把模板?