I'm using RequireJS with the text plugin for my HTML-templates.
define(
[
'text!./../../templates/twitterTemplate.html',
'jquery',
'underscore',
'backbone'
],
function(twitterTemplate, $, _, Backbone) {
var compiled = _.template(twitterTemplate);
return Backbone.View.extend({
el: '#tweets',
render: function() {
this.$el.append(compiled(this.model));
return this;
}
});
}
);
Everything works fine when running in a browser.
But when I run my jasmine-tests from Node.js, I get the following error when Node.js require
is trying to load the twitterTemplate.html
file:
(function (exports, require, module, __filename, __dirname) { <h4><%= title %>
^
Message:
SyntaxError: Unexpected token <
Stacktrace:
SyntaxError: Unexpected token <
at Module._compile (module.js:437:25)
at Object.Module._extensions..js (module.js:467:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Module.require (module.js:362:17)
I've probably misunderstood something. Grateful for answers that helps me solve this issue.
Thanks!