var nunjucks = require('nunjucks');
var minify = require('html-minifier').minify;

var FileSystemLoader = nunjucks.FileSystemLoader;
var defaultMinifyOpts = {
	removeComments: true,
	collapseWhitespace: true,
	minifyJS: true,
	minifyCSS: true,
	ignoreCustomFragments: [/\{\%[^}]+\%\}/]
};

var FileMinifyLoader = FileSystemLoader.extend({
	init: function(searchPaths, opts) {
		this.minifyOpts = opts.minify || defaultMinifyOpts;

		if (!this.minifyOpts.ignoreCustomFragments) {
			this.minifyOpts.ignoreCustomFragments = defaultMinifyOpts.ignoreCustomFragments;
		}

		FileSystemLoader.prototype.init.call(this, searchPaths, opts);
	},

	getSource: function(name) {
		var result = FileSystemLoader.prototype.getSource.call(this, name);

		if (!result) return null;

		result.src = minify(result.src, this.minifyOpts);
		return result;
	}
});

module.exports = FileMinifyLoader;
@@ -371,16 +371,92 @@
 ts) %7B%0A%09%09
+if(opts && opts.minify) %7B%0A%09%09%09this.minifyOpts = opts.minify;%0A%09%09%7D%0A%09%09else %7B%0A%09%09%09
 this.min
@@ -468,23 +468,8 @@
 ts =
- opts.minify %7C%7C
  def
@@ -483,16 +483,20 @@
 ifyOpts;
+%0A%09%09%7D
 %0A%0A%09%09if (

Fix when opts is undefined in FileMinifyLoader construct