From 3d86fd21ea472dda3aa3e329ba6a5d54319b0c23 Mon Sep 17 00:00:00 2001 From: Eric Clemmons Date: Thu, 17 Oct 2013 11:17:54 -0500 Subject: [PATCH 1/3] Fix options.htmlmin check --- tasks/lib/compiler.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tasks/lib/compiler.js b/tasks/lib/compiler.js index 0613ead..b85886e 100644 --- a/tasks/lib/compiler.js +++ b/tasks/lib/compiler.js @@ -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) { From 44d4198adf7e3b3dbba8411f8b94150805cc3cc5 Mon Sep 17 00:00:00 2001 From: Eric Clemmons Date: Thu, 17 Oct 2013 11:27:32 -0500 Subject: [PATCH 2/3] Fix regression in tests --- test/expected/callback_module.js | 4 ++-- test/expected/custom_angular.js | 4 ++-- test/expected/custom_bootstrap.js | 4 ++-- test/expected/custom_concat.js | 4 ++-- test/expected/custom_module.js | 4 ++-- test/expected/custom_source.js | 4 ++-- test/expected/custom_url.js | 4 ++-- test/expected/default_module.js | 4 ++-- test/expected/full_url.js | 4 ++-- test/expected/relative_url.js | 4 ++-- test/expected/standalone.js | 4 ++-- test/expected/undefined_file.js | 2 +- 12 files changed, 23 insertions(+), 23 deletions(-) diff --git a/test/expected/callback_module.js b/test/expected/callback_module.js index e7ca1cb..625594a 100644 --- a/test/expected/callback_module.js +++ b/test/expected/callback_module.js @@ -9,7 +9,7 @@ angular.module('test.fixtures.one.html').run(['$templateCache', function($templa " // Test\n" + " /* comments */\n" + " var foo = 'bar';\n" + - "" + "\n" ); }]); @@ -21,7 +21,7 @@ angular.module('test.fixtures.two.two.html').run(['$templateCache', function($te "\n" + "\n" + "\n" + - "" + "\n" ); }]); diff --git a/test/expected/custom_angular.js b/test/expected/custom_angular.js index d0ddd0e..8689cdd 100644 --- a/test/expected/custom_angular.js +++ b/test/expected/custom_angular.js @@ -9,7 +9,7 @@ myAngular.module('custom_angular').run(['$templateCache', function($templateCach " // Test\n" + " /* comments */\n" + " var foo = 'bar';\n" + - "" + "\n" ); @@ -18,7 +18,7 @@ myAngular.module('custom_angular').run(['$templateCache', function($templateCach "\n" + "\n" + "\n" + - "" + "\n" ); }]); diff --git a/test/expected/custom_bootstrap.js b/test/expected/custom_bootstrap.js index cc1eed9..54ab4a2 100644 --- a/test/expected/custom_bootstrap.js +++ b/test/expected/custom_bootstrap.js @@ -9,7 +9,7 @@ module.exports = function($templateCache) { " // Test\n" + " /* comments */\n" + " var foo = 'bar';\n" + - "" + "\n" ); @@ -18,7 +18,7 @@ module.exports = function($templateCache) { "\n" + "\n" + "\n" + - "" + "\n" ); }; diff --git a/test/expected/custom_concat.js b/test/expected/custom_concat.js index 41463a8..a9c4e99 100644 --- a/test/expected/custom_concat.js +++ b/test/expected/custom_concat.js @@ -20,7 +20,7 @@ angular.module('custom_concat').run(['$templateCache', function($templateCache) " // Test\n" + " /* comments */\n" + " var foo = 'bar';\n" + - "" + "\n" ); @@ -29,7 +29,7 @@ angular.module('custom_concat').run(['$templateCache', function($templateCache) "\n" + "\n" + "\n" + - "" + "\n" ); }]); diff --git a/test/expected/custom_module.js b/test/expected/custom_module.js index 2bb1956..f90593f 100644 --- a/test/expected/custom_module.js +++ b/test/expected/custom_module.js @@ -9,7 +9,7 @@ angular.module('customModule').run(['$templateCache', function($templateCache) { " // Test\n" + " /* comments */\n" + " var foo = 'bar';\n" + - "" + "\n" ); @@ -18,7 +18,7 @@ angular.module('customModule').run(['$templateCache', function($templateCache) { "\n" + "\n" + "\n" + - "" + "\n" ); }]); diff --git a/test/expected/custom_source.js b/test/expected/custom_source.js index fa2c664..57ac044 100644 --- a/test/expected/custom_source.js +++ b/test/expected/custom_source.js @@ -10,7 +10,7 @@ angular.module('custom_source').run(['$templateCache', function($templateCache) " // Test\n" + " /* comments */\n" + " var foo = 'bar';\n" + - "" + "\n" ); @@ -20,7 +20,7 @@ angular.module('custom_source').run(['$templateCache', function($templateCache) "\n" + "\n" + "\n" + - "" + "\n" ); }]); diff --git a/test/expected/custom_url.js b/test/expected/custom_url.js index 7d0ea79..aba4088 100644 --- a/test/expected/custom_url.js +++ b/test/expected/custom_url.js @@ -9,7 +9,7 @@ angular.module('custom_url').run(['$templateCache', function($templateCache) { " // Test\n" + " /* comments */\n" + " var foo = 'bar';\n" + - "" + "\n" ); @@ -18,7 +18,7 @@ angular.module('custom_url').run(['$templateCache', function($templateCache) { "\n" + "\n" + "\n" + - "" + "\n" ); }]); diff --git a/test/expected/default_module.js b/test/expected/default_module.js index d32d288..fadde3a 100644 --- a/test/expected/default_module.js +++ b/test/expected/default_module.js @@ -9,7 +9,7 @@ angular.module('default_module').run(['$templateCache', function($templateCache) " // Test\n" + " /* comments */\n" + " var foo = 'bar';\n" + - "" + "\n" ); @@ -18,7 +18,7 @@ angular.module('default_module').run(['$templateCache', function($templateCache) "\n" + "\n" + "\n" + - "" + "\n" ); }]); diff --git a/test/expected/full_url.js b/test/expected/full_url.js index 4312fc2..ab2a81f 100644 --- a/test/expected/full_url.js +++ b/test/expected/full_url.js @@ -9,7 +9,7 @@ angular.module('full_url').run(['$templateCache', function($templateCache) { " // Test\n" + " /* comments */\n" + " var foo = 'bar';\n" + - "" + "\n" ); @@ -18,7 +18,7 @@ angular.module('full_url').run(['$templateCache', function($templateCache) { "\n" + "\n" + "\n" + - "" + "\n" ); }]); diff --git a/test/expected/relative_url.js b/test/expected/relative_url.js index d6ce02c..580e6fc 100644 --- a/test/expected/relative_url.js +++ b/test/expected/relative_url.js @@ -9,7 +9,7 @@ angular.module('relative_url').run(['$templateCache', function($templateCache) { " // Test\n" + " /* comments */\n" + " var foo = 'bar';\n" + - "" + "\n" ); @@ -18,7 +18,7 @@ angular.module('relative_url').run(['$templateCache', function($templateCache) { "\n" + "\n" + "\n" + - "" + "\n" ); }]); diff --git a/test/expected/standalone.js b/test/expected/standalone.js index 047ea02..1776bd8 100644 --- a/test/expected/standalone.js +++ b/test/expected/standalone.js @@ -9,7 +9,7 @@ angular.module('standalone', []).run(['$templateCache', function($templateCache) " // Test\n" + " /* comments */\n" + " var foo = 'bar';\n" + - "" + "\n" ); @@ -18,7 +18,7 @@ angular.module('standalone', []).run(['$templateCache', function($templateCache) "\n" + "\n" + "\n" + - "" + "\n" ); }]); diff --git a/test/expected/undefined_file.js b/test/expected/undefined_file.js index c87a90b..9a26504 100644 --- a/test/expected/undefined_file.js +++ b/test/expected/undefined_file.js @@ -9,7 +9,7 @@ angular.module('undefined_file').run(['$templateCache', function($templateCache) " // Test\n" + " /* comments */\n" + " var foo = 'bar';\n" + - "" + "\n" ); }]); From 6a91681adff9051705b6600292f17827aa7b60d5 Mon Sep 17 00:00:00 2001 From: Eric Clemmons Date: Thu, 17 Oct 2013 11:28:00 -0500 Subject: [PATCH 3/3] Add specific test for html5 support --- Gruntfile.js | 5 +++++ test/angular-templates_test.js | 10 ++++++++++ test/expected/html5.js | 19 +++++++++++++++++++ test/fixtures/html5.html | 13 +++++++++++++ 4 files changed, 47 insertions(+) create mode 100644 test/expected/html5.js create mode 100644 test/fixtures/html5.html diff --git a/Gruntfile.js b/Gruntfile.js index a8a5bdd..7b6416a 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -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'], diff --git a/test/angular-templates_test.js b/test/angular-templates_test.js index affc630..baa74d2 100644 --- a/test/angular-templates_test.js +++ b/test/angular-templates_test.js @@ -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); diff --git a/test/expected/html5.js b/test/expected/html5.js new file mode 100644 index 0000000..1cb0fe6 --- /dev/null +++ b/test/expected/html5.js @@ -0,0 +1,19 @@ +angular.module('html5').run(['$templateCache', function($templateCache) { + + $templateCache.put('test/fixtures/html5.html', + "
\n" + + " \n" + + " Self-closing, sucka!\n" + + "
\n" + + " \n" + + "
\n" + + "\n" + + "
\n" + + "\n" + + "\n" + + " \n" + + "
\n" + + " Howdy\n" + ); + +}]); diff --git a/test/fixtures/html5.html b/test/fixtures/html5.html new file mode 100644 index 0000000..eb522da --- /dev/null +++ b/test/fixtures/html5.html @@ -0,0 +1,13 @@ +
+ + Self-closing, sucka! +
+ +
+ +
+ + + +
+ Howdy