gulp-ng-html2js
Advanced tools
Comparing version 0.1.6 to 0.1.7
11
index.js
@@ -9,2 +9,6 @@ var util = require("util"); | ||
var TEMPLATE_DECLARED_MODULE = "angular.module(\'%s\').run([\'$templateCache\', function($templateCache) {\n" + | ||
" $templateCache.put(\'%s\',\n \'%s\');\n" + | ||
"}]);\n"; | ||
var SINGLE_MODULE_TPL = "(function(module) {\n" + | ||
@@ -27,2 +31,3 @@ "try {\n" + | ||
* @param [options.moduleName] - The name of the module which will be generated. When omitted the fileUrl will be used. | ||
* @param [options.declareModule] - Whether to try to create the module. Default true, if false it will not create options.moduleName. | ||
* @param [options.stripPrefix] - The prefix which should be stripped from the file path | ||
@@ -60,3 +65,7 @@ * @param [options.prefix] - The prefix which should be added to the start of the url | ||
if(options && options.moduleName){ | ||
return util.format(SINGLE_MODULE_TPL, options.moduleName, options.moduleName, fileUrl, escapedContent); | ||
if (options.declareModule === false) { | ||
return util.format(TEMPLATE_DECLARED_MODULE, options.moduleName, fileUrl, escapedContent); | ||
} else { | ||
return util.format(SINGLE_MODULE_TPL, options.moduleName, options.moduleName, fileUrl, escapedContent); | ||
} | ||
} | ||
@@ -63,0 +72,0 @@ else{ |
{ | ||
"name": "gulp-ng-html2js", | ||
"version": "0.1.6", | ||
"version": "0.1.7", | ||
"description": "A Gulp plugin which generates AngularJS modules, which pre-load your HTML code into the $templateCache. This way AngularJS doesn't need to request the actual HTML files anymore.", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -64,2 +64,9 @@ # gulp-ng-html2js [![NPM version][npm-image]][npm-url] [![Build Status][travis-image]][travis-url] [![Dependency Status][depstat-image]][depstat-url] | ||
#### options.declareModule | ||
Type: `Boolean` | ||
Whether to attempt to declare a new module (used with options.moduleName). True if omitted. | ||
Set this to false if options.moduleName is already declared. | ||
#### options.prefix | ||
@@ -66,0 +73,0 @@ Type: `String` |
@@ -40,2 +40,18 @@ /*global describe, it*/ | ||
it("should use options.moduleName && options.declareModule when provided", function(done){ | ||
var expectedFile = new gutil.File({ | ||
path: "test/expected/exampleWithModuleName.js", | ||
cwd: "test/", | ||
base: "test/expected", | ||
contents: fs.readFileSync("test/expected/exampleWithModuleNameNoGenerate.js") | ||
}); | ||
var params = { | ||
moduleName: "myAwesomePartials", | ||
declareModule: false | ||
}; | ||
testBufferedFile(params, expectedFile, done); | ||
}); | ||
it("should add options.prefix to the url in the generated file", function(done){ | ||
@@ -42,0 +58,0 @@ var expectedFile = new gutil.File({ |
Sorry, the diff of this file is not supported yet
23263
17
463
104