grunt-angular-templates
Advanced tools
Comparing version 0.3.10 to 0.3.11
@@ -50,3 +50,36 @@ /* | ||
}, | ||
htmlmin: { | ||
options: { | ||
collapseBooleanAttributes: true, | ||
collapseWhitespace: true, | ||
removeAttributeQuotes: true, | ||
removeComments: true, | ||
removeEmptyAttributes: true, | ||
removeRedundantAttributes: true | ||
} | ||
}, | ||
ngtemplates: { | ||
htmlmin: { | ||
options: { | ||
base: 'test/fixtures', | ||
htmlmin: { | ||
collapseBooleanAttributes: true, | ||
collapseWhitespace: true, | ||
removeAttributeQuotes: true, | ||
removeComments: true, | ||
removeEmptyAttributes: true, | ||
removeRedundantAttributes: true | ||
} | ||
}, | ||
src: 'test/fixtures/markup.html', | ||
dest: 'tmp/markup.js' | ||
}, | ||
htmlmin_options: { | ||
options: { | ||
base: 'test/fixtures', | ||
htmlmin: '<%= htmlmin.options %>', | ||
}, | ||
src: 'test/fixtures/markup.html', | ||
dest: 'tmp/markup_options.js' | ||
}, | ||
multiple: { | ||
@@ -53,0 +86,0 @@ options: { |
{ | ||
"name": "grunt-angular-templates", | ||
"description": "Grunt build task to concatenate & register your AngularJS templates in the $templateCache", | ||
"version": "0.3.10", | ||
"version": "0.3.11", | ||
"homepage": "https://github.com/ericclemmons/grunt-angular-templates", | ||
@@ -35,3 +35,4 @@ "author": { | ||
"grunt-contrib-nodeunit": "~0.1.2", | ||
"grunt-cli": "~0.1.6" | ||
"grunt-cli": "~0.1.6", | ||
"html-minifier": "~0.5.2" | ||
}, | ||
@@ -38,0 +39,0 @@ "keywords": [ |
@@ -48,2 +48,6 @@ # grunt-angular-templates [![Build Status](https://travis-ci.org/ericclemmons/grunt-angular-templates.png?branch=master)](https://travis-ci.org/ericclemmons/grunt-angular-templates) | ||
noConflict: 'otherAngular' // (Optional) Name of angular.noConflict() app uses | ||
htmlmin: { // (Optional) html-minifier options. Can also be '<%= htmlmin.options %>' | ||
... | ||
} | ||
}, | ||
@@ -173,2 +177,6 @@ src: 'src/views/**.html', | ||
### v0.3.11 | ||
- Add `htmlmin` option that supports both an `{ ... }` and `<%= htmlmin.options %>` for existing tasks. | ||
### v0.3.10 | ||
@@ -175,0 +183,0 @@ |
@@ -11,3 +11,4 @@ /* | ||
var path = require('path'); | ||
var minify = require('html-minifier').minify; | ||
var path = require('path'); | ||
@@ -20,3 +21,13 @@ module.exports.init = function(grunt) { | ||
var template = '\n $templateCache.put("<%= id %>",\n <%= content %>\n );\n'; | ||
var cleaned = grunt.file.read(file).split(/^/gm).map(function(line) { return JSON.stringify(line); }).join(' +\n '); | ||
var source = grunt.file.read(file); | ||
if (options.htmlmin) { | ||
try { | ||
source = minify(source, options.htmlmin); | ||
} catch (err) { | ||
grunt.warn(file + '\n' + err); | ||
} | ||
} | ||
var cleaned = source.split(/^/gm).map(function(line) { return JSON.stringify(line); }).join(' +\n '); | ||
var cached = process(template, id, cleaned); | ||
@@ -23,0 +34,0 @@ |
@@ -106,4 +106,24 @@ 'use strict'; | ||
test.done(); | ||
}, | ||
markup: function(test) { | ||
test.expect(1); | ||
var actual = grunt.file.read('tmp/markup.js'); | ||
var expected = grunt.file.read('test/expected/markup.js'); | ||
test.equal(expected, actual, 'should create minified target that equals ngtemplate'); | ||
test.done(); | ||
}, | ||
markupOption: function(test) { | ||
test.expect(1); | ||
var actual = grunt.file.read('tmp/markup.js'); | ||
var expected = grunt.file.read('test/expected/markup_options.js'); | ||
test.equal(expected, actual, 'should create minified target that equals ngtemplate'); | ||
test.done(); | ||
} | ||
}; |
28833
24
449
271
6