ng-cache-loader
Advanced tools
Comparing version 0.0.22 to 0.0.23
10
index.js
@@ -11,2 +11,3 @@ /* | ||
var getTemplateId = require('./lib/templateId.js'); | ||
var getModuleId = require('./lib/moduleId.js'); | ||
@@ -49,3 +50,2 @@ var PRE_STUB = 'var angular=window.angular,ngModule;\n' + | ||
var opts = { | ||
module: 'ng', | ||
minimize: true, | ||
@@ -62,2 +62,3 @@ // next are html-minifier default options | ||
var minimizeOpts = this.query.match(/&?minimizeOptions[\s\n]*=[\s\n]*([^&]*)/); | ||
var moduleId = 'ng'; | ||
var result = []; | ||
@@ -117,4 +118,7 @@ var scripts; | ||
if (/[^\s]/.test(source) || !result.length) { | ||
var templateId = getTemplateId.call(this, source); | ||
var mod = getModuleId.call(this, templateId); | ||
moduleId = mod.moduleId; | ||
result.push({ | ||
key: getTemplateId.call(this, source), | ||
key: mod.templateId, | ||
val: resolveUrl(opts, source), | ||
@@ -135,5 +139,5 @@ i: result.length + 1, | ||
} | ||
result.unshift(supplant(PRE_STUB, {mod: opts.module})); | ||
result.unshift(supplant(PRE_STUB, {mod: moduleId})); | ||
return result.join('\n'); | ||
}; |
@@ -13,3 +13,3 @@ /* | ||
tag: { | ||
'[\\s\\n]src[\\s\\n]*=[\\s\\n]*[\'"]': 'srcAttr', | ||
'[\\s\\n](md-svg-)?src[\\s\\n]*=[\\s\\n]*[\'"]': 'srcAttr', | ||
'>': 'root', | ||
@@ -16,0 +16,0 @@ }, |
{ | ||
"name": "ng-cache-loader", | ||
"version": "0.0.22", | ||
"version": "0.0.23", | ||
"description": "Puts HTML partials in the Angular's $templateCache.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -145,2 +145,16 @@ # Angular Template loader for webpack | ||
#### Dynamic pattern for Module: | ||
``` javascript | ||
require('ng-cache?module=moduleName.[root]&prefix=packs:**!./packs/path/to/myPartial.html') | ||
``` | ||
In such query `[root]` means that first part of `templateId` *(here it is `path/to/myPartial.html`)* will be stripped out and placed as a part of `moduleId`. | ||
In current example resulting values: | ||
- `moduleId`: `"moduleName.path"` | ||
- `templateId`: `"to/myPartial.html"` | ||
Useful in case you want save few bytes. | ||
## Template id | ||
@@ -147,0 +161,0 @@ |
@@ -11,3 +11,5 @@ /** | ||
libPath = 'lib/templateId'; | ||
moduleLibPath = 'lib/moduleId'; | ||
lib = require(path.join(cwd, libPath)); | ||
moduleLib = require(path.join(cwd, moduleLibPath)); | ||
@@ -436,2 +438,26 @@ describe(libPath, function() { | ||
describe('module id pattern', function() { | ||
var params = { | ||
resource: 'template/popover/popover.html' | ||
}; | ||
it('#should replace root', function() { | ||
templateId = 'some/popover.html'; | ||
params.query = '?name=[file].[ext]&module=web.[root]'; | ||
expect(moduleLib.call(params, templateId)).to.deep.equal({moduleId: 'web.some', templateId: 'popover.html'}); | ||
}); | ||
it('#should replace nothing', function() { | ||
templateId = 'some/popover.html'; | ||
params.query = '?name=[file].[ext]&module=some'; | ||
expect(moduleLib.call(params, templateId)).to.deep.equal({moduleId: 'some', templateId: 'some/popover.html'}); | ||
}); | ||
it('#should be ng by default', function() { | ||
templateId = 'some/popover.html'; | ||
params.query = '?name=[file].[ext]'; | ||
expect(moduleLib.call(params, templateId)).to.deep.equal({moduleId: 'ng', templateId: 'some/popover.html'}); | ||
}); | ||
}); | ||
describe('various casese', function() { | ||
@@ -438,0 +464,0 @@ var resources = [ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
278
42274
852
2