2012-09-11 02:12:23 +08:00
|
|
|
var grunt = require('grunt');
|
|
|
|
|
|
|
|
exports['jst'] = {
|
|
|
|
main: function(test) {
|
|
|
|
'use strict';
|
|
|
|
|
2012-09-12 23:34:53 +08:00
|
|
|
var expect, result;
|
2012-09-11 02:12:23 +08:00
|
|
|
|
2012-09-12 23:34:53 +08:00
|
|
|
test.expect(2);
|
|
|
|
|
|
|
|
expect = 'this[\'JST\'] = this[\'JST\'] || {};\n\nthis[\'JST\'][\'test/fixtures/it\\\'s-a-bad-filename.html\'] = function(obj){\nvar __p=\'\';var print=function(){__p+=Array.prototype.join.call(arguments, \'\')};\nwith(obj||{}){\n__p+=\'never name your file like this.\';\n}\nreturn __p;\n};\n\nthis[\'JST\'][\'test/fixtures/template.html\'] = function(obj){\nvar __p=\'\';var print=function(){__p+=Array.prototype.join.call(arguments, \'\')};\nwith(obj||{}){\n__p+=\'<head><title>\'+\n( title )+\n\'</title></head>\';\n}\nreturn __p;\n};';
|
|
|
|
result = grunt.file.read("tmp/jst.js");
|
2012-09-11 02:12:23 +08:00
|
|
|
test.equal(expect, result, "should compile underscore templates into JST");
|
|
|
|
|
2012-09-12 23:34:53 +08:00
|
|
|
expect = 'this[\'JST\'] = this[\'JST\'] || {};\n\nthis[\'JST\'][\'test/fixtures/it\\\'s-a-bad-filename.html\'] = function(obj){\nvar __p=\'\';var print=function(){__p+=Array.prototype.join.call(arguments, \'\')};\nwith(obj||{}){\n__p+=\'never name your file like this.\';\n}\nreturn __p;\n};';
|
|
|
|
result = grunt.file.read("tmp/uglyfile.js");
|
|
|
|
test.equal(expect, result, "should escape single quotes in filenames");
|
|
|
|
|
2012-09-11 02:12:23 +08:00
|
|
|
test.done();
|
|
|
|
}
|
|
|
|
};
|