Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

ng-cache-loader

Package Overview
Dependencies
Maintainers
1
Versions
26
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ng-cache-loader - npm Package Compare versions

Comparing version 0.0.22 to 0.0.23

lib/moduleId.js

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 = [

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc