I'm working with ember
and gulpjs
to precompilate
the templates but I always I get the same mistake:
Error: Unknown template object: function
...e","number","stack"];return e.prototype=new Error,t=e}(),r=function(e,t){"use st...
This is the process with gulpjs
...
var handlebars = require('gulp-handlebars');
...
gulp.task('templates', function() {
// Load templates from the source/templates/ folder relative to where gulp was executed
gulp.src('./app/templates/**/*.hbs')
// Compile each Handlebars template source file to a template function using Ember's Handlebars
.pipe(handlebars({
handlebars: require('ember-handlebars')
}))
// Wrap each template function in a call to Ember.Handlebars.template
.pipe(wrap('Ember.Handlebars.template(<%= contents %>)'))
// Declare template functions with Ember.TEMPLATES according to their path and filename
.pipe(declare({
namespace: 'Ember.TEMPLATES',
noRedeclare: true, // Avoid duplicate declarations
processName: function(filePath) {
// Allow nesting based on path using gulp-declare's processNameByPath()
// You can remove this option completely if you aren't using nested folders
// Drop the source/templates/ folder from the namespace path by removing it from the filePath
return declare.processNameByPath(filePath.replace( './app/templates/', ''));
}
}))
// Concatenate down to a single file
.pipe(concat('templates.js'))
// Write the output into the templates folder
.pipe(gulp.dest('www/js/'));
});
The version with I precompile the templates are acording my package.json
"gulp-ember-handlebars": "^0.7.0",
"gulp-handlebars": "^3.0.0",
"handlebars": "^3.0.0",
And the versions of the templates interpreters according with my bower.json
"ember": "1.9.1",
"handlebars": "3.0.0"
In the index.html
I loaded the templates
<html>
<head>
<meta charset="utf-8" />
<!-- load jquery,emberjs,handlerbars an more -->
<script src="js/vendors.js"></script>
</head>
<body>
<script src="js/main.js"></script> <!-- controllers from ember...-->
<script src="js/templates.js"></script>
</body>
</html>
And the compiled templates generate it (templates.js
):
this["Ember"] = this["Ember"] || {};
this["Ember"]["TEMPLATES"] = this["Ember"]["TEMPLATES"] || {};
this["Ember"]["TEMPLATES"]["app"] = this["Ember"]["TEMPLATES"]["app"] || {};
this["Ember"]["TEMPLATES"]["app"]["templates"] = this["Ember"]["TEMPLATES"]["app"]["templates"] || {};
this["Ember"]["TEMPLATES"]["app"]["templates"]["index"] = Ember.Handlebars.template(function anonymous(Handlebars,depth0,helpers,partials,data) {
this.compilerInfo = [4,'>= 1.0.0'];
helpers = this.merge(helpers, Ember.Handlebars.helpers); data = data || {};
data.buffer.push("Hello world :D \n");
});
So I'm wondering what am I doing wrong?
Aucun commentaire:
Enregistrer un commentaire