Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix regression with htmlmin & HTML5 #54

Merged
merged 3 commits into from
Oct 18, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,11 @@ module.exports = function(grunt) {
}
},

html5: {
src: ['test/fixtures/html5.html'],
dest: 'tmp/html5.js'
},

// Minify the HTML
custom_htmlmin: {
src: ['test/fixtures/one.html', 'test/fixtures/two/**/*.html'],
Expand Down
2 changes: 1 addition & 1 deletion tasks/lib/compiler.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ var Compiler = function(grunt, options, cwd) {
* @return {String} Minified template
*/
this.minify = function(source) {
if (options.htmlmin) {
if (Object.keys(options.htmlmin).length) {
try {
source = minify(source, options.htmlmin);
} catch (err) {
Expand Down
10 changes: 10 additions & 0 deletions test/angular-templates_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,16 @@ exports.ngtemplates = {
test.done();
},

html5: function(test) {
test.expect(1);

var actual = grunt.file.read('tmp/html5.js');
var expected = grunt.file.read('test/expected/html5.js');

test.equal(expected, actual);
test.done();
},

custom_htmlmin: function(test) {
test.expect(1);

Expand Down
4 changes: 2 additions & 2 deletions test/expected/callback_module.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ angular.module('test.fixtures.one.html').run(['$templateCache', function($templa
" // Test\n" +
" /* comments */\n" +
" var foo = 'bar';\n" +
"</script>"
"</script>\n"
);

}]);
Expand All @@ -21,7 +21,7 @@ angular.module('test.fixtures.two.two.html').run(['$templateCache', function($te
"\n" +
"<!-- Comment for two -->\n" +
"\n" +
"<textarea readonly=\"readonly\">We are two.</textarea>"
"<textarea readonly=\"readonly\">We are two.</textarea>\n"
);

}]);
4 changes: 2 additions & 2 deletions test/expected/custom_angular.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ myAngular.module('custom_angular').run(['$templateCache', function($templateCach
" // Test\n" +
" /* comments */\n" +
" var foo = 'bar';\n" +
"</script>"
"</script>\n"
);


Expand All @@ -18,7 +18,7 @@ myAngular.module('custom_angular').run(['$templateCache', function($templateCach
"\n" +
"<!-- Comment for two -->\n" +
"\n" +
"<textarea readonly=\"readonly\">We are two.</textarea>"
"<textarea readonly=\"readonly\">We are two.</textarea>\n"
);

}]);
4 changes: 2 additions & 2 deletions test/expected/custom_bootstrap.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ module.exports = function($templateCache) {
" // Test\n" +
" /* comments */\n" +
" var foo = 'bar';\n" +
"</script>"
"</script>\n"
);


Expand All @@ -18,7 +18,7 @@ module.exports = function($templateCache) {
"\n" +
"<!-- Comment for two -->\n" +
"\n" +
"<textarea readonly=\"readonly\">We are two.</textarea>"
"<textarea readonly=\"readonly\">We are two.</textarea>\n"
);

};
4 changes: 2 additions & 2 deletions test/expected/custom_concat.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ angular.module('custom_concat').run(['$templateCache', function($templateCache)
" // Test\n" +
" /* comments */\n" +
" var foo = 'bar';\n" +
"</script>"
"</script>\n"
);


Expand All @@ -29,7 +29,7 @@ angular.module('custom_concat').run(['$templateCache', function($templateCache)
"\n" +
"<!-- Comment for two -->\n" +
"\n" +
"<textarea readonly=\"readonly\">We are two.</textarea>"
"<textarea readonly=\"readonly\">We are two.</textarea>\n"
);

}]);
4 changes: 2 additions & 2 deletions test/expected/custom_module.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ angular.module('customModule').run(['$templateCache', function($templateCache) {
" // Test\n" +
" /* comments */\n" +
" var foo = 'bar';\n" +
"</script>"
"</script>\n"
);


Expand All @@ -18,7 +18,7 @@ angular.module('customModule').run(['$templateCache', function($templateCache) {
"\n" +
"<!-- Comment for two -->\n" +
"\n" +
"<textarea readonly=\"readonly\">We are two.</textarea>"
"<textarea readonly=\"readonly\">We are two.</textarea>\n"
);

}]);
4 changes: 2 additions & 2 deletions test/expected/custom_source.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ angular.module('custom_source').run(['$templateCache', function($templateCache)
" // Test\n" +
" /* comments */\n" +
" var foo = 'bar';\n" +
"</script>"
"</script>\n"
);


Expand All @@ -20,7 +20,7 @@ angular.module('custom_source').run(['$templateCache', function($templateCache)
"\n" +
"<!-- Comment for two -->\n" +
"\n" +
"<textarea readonly=\"readonly\">We are two.</textarea>"
"<textarea readonly=\"readonly\">We are two.</textarea>\n"
);

}]);
4 changes: 2 additions & 2 deletions test/expected/custom_url.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ angular.module('custom_url').run(['$templateCache', function($templateCache) {
" // Test\n" +
" /* comments */\n" +
" var foo = 'bar';\n" +
"</script>"
"</script>\n"
);


Expand All @@ -18,7 +18,7 @@ angular.module('custom_url').run(['$templateCache', function($templateCache) {
"\n" +
"<!-- Comment for two -->\n" +
"\n" +
"<textarea readonly=\"readonly\">We are two.</textarea>"
"<textarea readonly=\"readonly\">We are two.</textarea>\n"
);

}]);
4 changes: 2 additions & 2 deletions test/expected/default_module.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ angular.module('default_module').run(['$templateCache', function($templateCache)
" // Test\n" +
" /* comments */\n" +
" var foo = 'bar';\n" +
"</script>"
"</script>\n"
);


Expand All @@ -18,7 +18,7 @@ angular.module('default_module').run(['$templateCache', function($templateCache)
"\n" +
"<!-- Comment for two -->\n" +
"\n" +
"<textarea readonly=\"readonly\">We are two.</textarea>"
"<textarea readonly=\"readonly\">We are two.</textarea>\n"
);

}]);
4 changes: 2 additions & 2 deletions test/expected/full_url.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ angular.module('full_url').run(['$templateCache', function($templateCache) {
" // Test\n" +
" /* comments */\n" +
" var foo = 'bar';\n" +
"</script>"
"</script>\n"
);


Expand All @@ -18,7 +18,7 @@ angular.module('full_url').run(['$templateCache', function($templateCache) {
"\n" +
"<!-- Comment for two -->\n" +
"\n" +
"<textarea readonly=\"readonly\">We are two.</textarea>"
"<textarea readonly=\"readonly\">We are two.</textarea>\n"
);

}]);
19 changes: 19 additions & 0 deletions test/expected/html5.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
angular.module('html5').run(['$templateCache', function($templateCache) {

$templateCache.put('test/fixtures/html5.html',
"<div>\n" +
" <span>\n" +
" Self-closing, sucka!\n" +
" <br>\n" +
" <img src='path/to/img'>\n" +
"</div>\n" +
"\n" +
"<hr>\n" +
"\n" +
"<table>\n" +
" <tr>\n" +
" <td>\n" +
" Howdy\n"
);

}]);
4 changes: 2 additions & 2 deletions test/expected/relative_url.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ angular.module('relative_url').run(['$templateCache', function($templateCache) {
" // Test\n" +
" /* comments */\n" +
" var foo = 'bar';\n" +
"</script>"
"</script>\n"
);


Expand All @@ -18,7 +18,7 @@ angular.module('relative_url').run(['$templateCache', function($templateCache) {
"\n" +
"<!-- Comment for two -->\n" +
"\n" +
"<textarea readonly=\"readonly\">We are two.</textarea>"
"<textarea readonly=\"readonly\">We are two.</textarea>\n"
);

}]);
4 changes: 2 additions & 2 deletions test/expected/standalone.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ angular.module('standalone', []).run(['$templateCache', function($templateCache)
" // Test\n" +
" /* comments */\n" +
" var foo = 'bar';\n" +
"</script>"
"</script>\n"
);


Expand All @@ -18,7 +18,7 @@ angular.module('standalone', []).run(['$templateCache', function($templateCache)
"\n" +
"<!-- Comment for two -->\n" +
"\n" +
"<textarea readonly=\"readonly\">We are two.</textarea>"
"<textarea readonly=\"readonly\">We are two.</textarea>\n"
);

}]);
2 changes: 1 addition & 1 deletion test/expected/undefined_file.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ angular.module('undefined_file').run(['$templateCache', function($templateCache)
" // Test\n" +
" /* comments */\n" +
" var foo = 'bar';\n" +
"</script>"
"</script>\n"
);

}]);
13 changes: 13 additions & 0 deletions test/fixtures/html5.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<div>
<span>
Self-closing, sucka!
<br>
<img src='path/to/img'>
</div>

<hr>

<table>
<tr>
<td>
Howdy