ng-cache-loader
Advanced tools
Comparing version 0.0.16 to 0.0.17
48
index.js
@@ -17,12 +17,13 @@ /* | ||
var STUB = 'var v${i}=${val};\n' + | ||
'ngModule.run(["$templateCache",function(c){c.put("${key}",v${i})}]);'; | ||
'var id${i}="${key}";\n' + | ||
'ngModule.run(["$templateCache",function(c){c.put(id${i},v${i})}]);'; | ||
/** | ||
* Replaces placeholders with values. | ||
* @param {string} stub | ||
* @param {string} stub Template ith placeholders. | ||
* @param {Object} values Key-value pairs. | ||
* @returns {string} | ||
* @return {string} Resolved template. | ||
*/ | ||
function supplant (stub, values) { | ||
return stub.replace(/\$\{([^}]+)\}/g, function (match, key) { | ||
function supplant(stub, values) { | ||
return stub.replace(/\$\{([^}]+)\}/g, function(match, key) { | ||
return values[key] || match; | ||
@@ -32,14 +33,14 @@ }); | ||
/** | ||
* Replaces urls with `require(url)` for further processing in url-loader or file-loader. | ||
* Replaces urls with `require(url)` for further processing with url-loader or file-loader. | ||
* @param {Object} query ng-cache-loader options. | ||
* @param {string} src | ||
* @returns {string} JSON | ||
* @param {string} src Template text. | ||
* @return {string} JSON | ||
*/ | ||
function resolveUrl (query, src) { | ||
return query.url !== false ? | ||
urlParser(src) : | ||
JSON.stringify(src); | ||
function resolveUrl(query, src) { | ||
return query.url === false ? | ||
JSON.stringify(src) : | ||
urlParser(src); | ||
} | ||
module.exports = function (source) { | ||
module.exports = function(source) { | ||
var opts = { | ||
@@ -54,9 +55,13 @@ module: 'ng', | ||
removeEmptyAttributes: true, | ||
keepClosingSlash: true | ||
keepClosingSlash: true, | ||
}; | ||
var minimizeOpts = this.query.match(/&?minimizeOptions[\s\n]*=[\s\n]*([^&]*)/); | ||
var result = []; | ||
var scripts, html, scr; | ||
var scripts; | ||
var html; | ||
var scr; | ||
this.cacheable && this.cacheable(); | ||
if (this.cacheable) { | ||
this.cacheable(); | ||
} | ||
@@ -96,3 +101,3 @@ // Remove minimizeOptions from query string because JSON is not suitable for query parameter | ||
val: resolveUrl(opts, html), | ||
i: result.length + 1 | ||
i: result.length + 1, | ||
}); | ||
@@ -110,3 +115,3 @@ } else { | ||
val: resolveUrl(opts, source), | ||
i: result.length + 1 | ||
i: result.length + 1, | ||
}); | ||
@@ -116,3 +121,8 @@ } | ||
result.push('module.exports=v' + result.length + ';'); | ||
// Return template string or id/template pair as module exports | ||
if (opts.exportId) { | ||
result.push('exports.id=id' + result.length + ';\nexports.template=v' + result.length + ';'); | ||
} else { | ||
result.push('module.exports=v' + result.length + ';'); | ||
} | ||
result.unshift(supplant(PRE_STUB, {mod: opts.module})); | ||
@@ -119,0 +129,0 @@ |
@@ -9,7 +9,7 @@ /* | ||
root: { | ||
'<script': function (match, idx) { | ||
'<script': function(match, idx) { | ||
this.idx = idx; | ||
return 'scriptTag'; | ||
}, | ||
'<\\/script[\\s\\n]*>': function (match, idx, len) { | ||
'<\\/script[\\s\\n]*>': function(match, idx, len) { | ||
if (this.isTemplate) { | ||
@@ -21,28 +21,28 @@ this.scripts.push({ | ||
contIdx: this.contIdx, // content begin index | ||
contLen: idx - this.idx - this.contIdx // content up to final script tag length | ||
contLen: idx - this.idx - this.contIdx, // content up to final script tag length | ||
}); | ||
} | ||
this.isTemplate = this.idx = this.contIdx = this.id = undefined; | ||
} | ||
}, | ||
}, | ||
scriptTag: { | ||
'type[\\s\\n]*=[\\s\\n]*[\'\"]': 'typeAttr', | ||
'id[\\s\\n]*=[\\s\\n]*[\'\"]': 'idAttr', | ||
'>': function (match, idx) { | ||
'type[\\s\\n]*=[\\s\\n]*[\'"]': 'typeAttr', | ||
'id[\\s\\n]*=[\\s\\n]*[\'"]': 'idAttr', | ||
'>': function(match, idx) { | ||
this.contIdx = idx - this.idx + 1; | ||
return 'root'; | ||
} | ||
}, | ||
}, | ||
typeAttr: { | ||
'text/ng-template': function () { | ||
'text/ng-template': function() { | ||
this.isTemplate = true; | ||
}, | ||
'[\'\"]': 'scriptTag' | ||
'[\'"]': 'scriptTag', | ||
}, | ||
idAttr: { | ||
'[^\'\"\\s\\n]+': function (match) { | ||
'[^\'"\\s\\n]+': function(match) { | ||
this.id = match; | ||
}, | ||
'[\'\"]': 'scriptTag' | ||
} | ||
'[\'"]': 'scriptTag', | ||
}, | ||
}); |
@@ -12,3 +12,3 @@ /* | ||
* @param {string} file File name. With prefix if defined. | ||
* @returns {*} | ||
* @return {*} File name according with template. | ||
*/ | ||
@@ -19,8 +19,9 @@ var processName = function(pattern, source, file) { | ||
ext: '', | ||
hash: '[hash]' | ||
hash: '[hash]', | ||
}; | ||
var re = new RegExp('\\[(' + Object.keys(params).join('|') + ')\\]', 'g'); | ||
var splitted; | ||
var isValid; | ||
var match; | ||
var isValid; | ||
var splitted; | ||
var name; | ||
@@ -61,5 +62,5 @@ if (pattern) { | ||
* @param {string} source Template content. | ||
* @returns {string} | ||
* @return {string} Template ID. | ||
*/ | ||
module.exports = function (source) { | ||
module.exports = function(source) { | ||
var sep = '/'; | ||
@@ -73,3 +74,7 @@ var rootSep = ':'; | ||
var path = this.resource; | ||
var root, file, dir, isAbsolute, i; | ||
var isAbsolute; | ||
var root; | ||
var file; | ||
var dir; | ||
var i; | ||
@@ -104,3 +109,3 @@ // Change separators to unix style | ||
// Split prefix and replace `[dirs]` by `**` for consistency | ||
pref = pref.split(sep).map(function (dir) { | ||
pref = pref.split(sep).map(function(dir) { | ||
return ~dirsPh.indexOf(dir) ? dirsPh[0] : dir; | ||
@@ -120,3 +125,3 @@ }); | ||
// Replace `**` by a number of `*` in accordance with the path length | ||
pref = pref.reduce(function (res, dir, i) { | ||
pref = pref.reduce(function(res, dir, i) { | ||
var n = 1; | ||
@@ -149,3 +154,3 @@ | ||
} | ||
// Return first empty chunk to be absolute | ||
@@ -155,3 +160,3 @@ if (isAbsolute && pref[0]) { | ||
} | ||
pref.push(file); | ||
@@ -158,0 +163,0 @@ file = pref.join(sep); |
@@ -10,22 +10,23 @@ /* | ||
root: { | ||
'<[^\\s/>]+': 'tag' | ||
'<[^\\s/>]+': 'tag', | ||
}, | ||
tag: { | ||
'[\\s\\n]src[\\s\\n]*=[\\s\\n]*[\'\"]': 'srcAttr', | ||
'>': 'root' | ||
'[\\s\\n]src[\\s\\n]*=[\\s\\n]*[\'"]': 'srcAttr', | ||
'>': 'root', | ||
}, | ||
srcAttr: { | ||
'[^\'\"]+': function (match, idx) { | ||
if (relativeImageUrl.test(match)) | ||
this.urls.push({ idx: idx, path: match }); | ||
'[^\'"]+': function(match, idx) { | ||
if (relativeImageUrl.test(match)) { | ||
this.urls.push({idx: idx, path: match}); | ||
} | ||
return 'tag'; | ||
}, | ||
'[\'\"]': 'tag' | ||
} | ||
'[\'"]': 'tag', | ||
}, | ||
}); | ||
module.exports = function (src) { | ||
var urls = Parser.parse('root', src, { urls: [] }).urls, | ||
i = urls.length, | ||
result = []; | ||
module.exports = function(src) { | ||
var urls = Parser.parse('root', src, {urls: []}).urls; | ||
var i = urls.length; | ||
var result = []; | ||
@@ -32,0 +33,0 @@ while (i--) { |
{ | ||
"name": "ng-cache-loader", | ||
"version": "0.0.16", | ||
"version": "0.0.17", | ||
"description": "Puts HTML partials in the Angular's $templateCache.", | ||
@@ -24,2 +24,4 @@ "main": "index.js", | ||
"chai": "^3.2.0", | ||
"eslint": "^2.13.1", | ||
"eslint-config-google": "^0.6.0", | ||
"mocha": "^2.3.0", | ||
@@ -26,0 +28,0 @@ "webpack": "^1.4.3" |
@@ -121,3 +121,3 @@ # Angular Template loader for webpack | ||
Use `name` query parameter to stip file extension or add suffix: | ||
Use `name` query parameter to strip file extension or add suffix: | ||
@@ -146,2 +146,13 @@ ``` javascript | ||
## Template id | ||
To obtain template id use `exportId` query parameter. Loader exports object with `id` and `template` keys. | ||
```javascript | ||
var template = require('ng-cache?exportId!./field.html') | ||
$('#wrapper').html(`<div id="bootstrapElement" data-ng-include="'${template.id}'"></div>`); | ||
angular.bootstrap($('#bootstrapElement'), [someModule]); | ||
``` | ||
## Webpack config | ||
@@ -148,0 +159,0 @@ |
@@ -58,7 +58,10 @@ /******/ (function(modules) { // webpackBootstrap | ||
var v1="<div class=\"view\">\n <p>...</p>\n </div>"; | ||
ngModule.run(["$templateCache",function(c){c.put("myAnotherTemplate",v1)}]); | ||
var id1="myAnotherTemplate"; | ||
ngModule.run(["$templateCache",function(c){c.put(id1,v1)}]); | ||
var v2="<div class=\"view\">\n <h2>First View</h2>\n <p>\n Search:<input type=\"text\" ng-model=\"filterText\" />\n </p>\n </div>"; | ||
ngModule.run(["$templateCache",function(c){c.put("myTemplate",v2)}]); | ||
var id2="myTemplate"; | ||
ngModule.run(["$templateCache",function(c){c.put(id2,v2)}]); | ||
var v3=" <div class=\"view\"> <h2>Second View</h2> <p>About me</p> </div> <div class=\"view\"> <h2>Second View</h2> <p>About you</p> </div> <div class=\"view\"></div>"; | ||
ngModule.run(["$templateCache",function(c){c.put("grot/teux/ng-cache-loader/tmpl/template.tpl",v3)}]); | ||
var id3="grot/teux/ng-cache-loader/tmpl/template.tpl"; | ||
ngModule.run(["$templateCache",function(c){c.put(id3,v3)}]); | ||
module.exports=v3; | ||
@@ -65,0 +68,0 @@ |
@@ -7,3 +7,4 @@ /** | ||
var cwd = process.cwd(); | ||
var libPath, lib; | ||
var libPath; | ||
var lib; | ||
@@ -13,3 +14,3 @@ libPath = 'lib/templateId'; | ||
describe(libPath, function () { | ||
describe(libPath, function() { | ||
var resources = [ | ||
@@ -19,3 +20,3 @@ '/Users/myself/Projects/packman/web_modules/angular-ui-bootstrap/template/popover/popover.html', | ||
'W:\\Projects\\packman\\web_modules\\angular-ui-bootstrap\\template\\popover\\popover.html', | ||
'W:\\Projects\\packman\\components\\article\\actions\\actions.html' | ||
'W:\\Projects\\packman\\components\\article\\actions\\actions.html', | ||
]; | ||
@@ -26,5 +27,5 @@ /** | ||
* @param {string} [prefix] Prefix. | ||
* @returns {string} Result | ||
* @return {string} Result | ||
*/ | ||
var run = function (resource, prefix) { | ||
var run = function(resource, prefix) { | ||
var params = {resource: resource}; | ||
@@ -38,10 +39,12 @@ | ||
var getFile = function (path) { | ||
var getFile = function(path) { | ||
return path.replace(/\\/g, '/').split('/').pop(); | ||
}; | ||
var alternation = function (res, pref) { | ||
var odd, abs; | ||
var alternation = function(res, pref) { | ||
var odd; | ||
var abs; | ||
pref = pref.replace(/\\/g, '/').split('/'); | ||
if (pref[0] === '') { | ||
@@ -64,5 +67,5 @@ abs = true; | ||
describe('without prefix', function () { | ||
it('#should return file name', function () { | ||
resources.forEach(function (res) { | ||
describe('without prefix', function() { | ||
it('#should return file name', function() { | ||
resources.forEach(function(res) { | ||
var file = getFile(res); | ||
@@ -75,18 +78,18 @@ expect(run(res)).to.equal(file); | ||
describe('explicit prefix', function () { | ||
it('#should be relative', function () { | ||
describe('explicit prefix', function() { | ||
it('#should be relative', function() { | ||
var pref = 'app/tmpl'; | ||
resources.forEach(function (res) { | ||
resources.forEach(function(res) { | ||
expect(run(res, pref)).to.equal(pref + '/' + getFile(res)); | ||
}); | ||
}); | ||
it('#should be absolute', function () { | ||
it('#should be absolute', function() { | ||
var pref = '/app/tmpl'; | ||
resources.forEach(function (res) { | ||
resources.forEach(function(res) { | ||
expect(run(res, pref)).to.equal(pref + '/' + getFile(res)); | ||
}); | ||
}); | ||
it('#should be absolute without unnecessary slash', function () { | ||
it('#should be absolute without unnecessary slash', function() { | ||
var pref = '/app/tmpl/'; | ||
resources.forEach(function (res) { | ||
resources.forEach(function(res) { | ||
expect(run(res, pref)).to.equal(pref + getFile(res)); | ||
@@ -97,18 +100,18 @@ }); | ||
describe('explicit prefix (Win style)', function () { | ||
it('#should be relative', function () { | ||
describe('explicit prefix (Win style)', function() { | ||
it('#should be relative', function() { | ||
var pref = 'app\\tmpl'; | ||
resources.forEach(function (res) { | ||
resources.forEach(function(res) { | ||
expect(run(res, pref)).to.equal('app/tmpl/' + getFile(res)); | ||
}); | ||
}); | ||
it('#should be absolute', function () { | ||
it('#should be absolute', function() { | ||
var pref = '\\app\\tmpl'; | ||
resources.forEach(function (res) { | ||
resources.forEach(function(res) { | ||
expect(run(res, pref)).to.equal('/app/tmpl/' + getFile(res)); | ||
}); | ||
}); | ||
it('#should be absolute without unnecessary slash', function () { | ||
it('#should be absolute without unnecessary slash', function() { | ||
var pref = '\\app\\tmpl\\'; | ||
resources.forEach(function (res) { | ||
resources.forEach(function(res) { | ||
expect(run(res, pref)).to.equal('/app/tmpl/' + getFile(res)); | ||
@@ -119,20 +122,20 @@ }); | ||
describe('take from path (relative prefix)', function () { | ||
it('#should take odd chunks', function () { | ||
describe('take from path (relative prefix)', function() { | ||
it('#should take odd chunks', function() { | ||
var pref = '*/dir1/*/dir2'; | ||
resources.forEach(function (res) { | ||
resources.forEach(function(res) { | ||
expect(run(res, pref)).to.equal(alternation(res, pref)); | ||
}); | ||
pref = '[dir]/dir1/[dir]/dir2'; | ||
resources.forEach(function (res) { | ||
resources.forEach(function(res) { | ||
expect(run(res, pref)).to.equal(alternation(res, pref)); | ||
}); | ||
}); | ||
it('#should take even chunks', function () { | ||
it('#should take even chunks', function() { | ||
var pref = 'dir1/*/dir2/*'; | ||
resources.forEach(function (res) { | ||
resources.forEach(function(res) { | ||
expect(run(res, pref)).to.equal(alternation(res, pref)); | ||
}); | ||
pref = 'dir1/[dir]/dir2/[dir]'; | ||
resources.forEach(function (res) { | ||
resources.forEach(function(res) { | ||
expect(run(res, pref)).to.equal(alternation(res, pref)); | ||
@@ -143,20 +146,20 @@ }); | ||
describe('take from path (absolute prefix)', function () { | ||
it('#should take odd chunks', function () { | ||
describe('take from path (absolute prefix)', function() { | ||
it('#should take odd chunks', function() { | ||
var pref = '/*/dir1/*/dir2'; | ||
resources.forEach(function (res) { | ||
resources.forEach(function(res) { | ||
expect(run(res, pref)).to.equal(alternation(res, pref)); | ||
}); | ||
pref = '/[dir]/dir1/[dir]/dir2'; | ||
resources.forEach(function (res) { | ||
resources.forEach(function(res) { | ||
expect(run(res, pref)).to.equal(alternation(res, pref)); | ||
}); | ||
}); | ||
it('#should take even chunks', function () { | ||
it('#should take even chunks', function() { | ||
var pref = '/dir1/*/dir2/*'; | ||
resources.forEach(function (res) { | ||
resources.forEach(function(res) { | ||
expect(run(res, pref)).to.equal(alternation(res, pref)); | ||
}); | ||
pref = '/dir1/[dir]/dir2/[dir]'; | ||
resources.forEach(function (res) { | ||
resources.forEach(function(res) { | ||
expect(run(res, pref)).to.equal(alternation(res, pref)); | ||
@@ -167,20 +170,20 @@ }); | ||
describe('take from path (relative prefix Win style)', function () { | ||
it('#should take odd chunks', function () { | ||
describe('take from path (relative prefix Win style)', function() { | ||
it('#should take odd chunks', function() { | ||
var pref = '*\\dir1\\*\\dir2'; | ||
resources.forEach(function (res) { | ||
resources.forEach(function(res) { | ||
expect(run(res, pref)).to.equal(alternation(res, pref)); | ||
}); | ||
pref = '[dir]\\dir1\\[dir]\\dir2'; | ||
resources.forEach(function (res) { | ||
resources.forEach(function(res) { | ||
expect(run(res, pref)).to.equal(alternation(res, pref)); | ||
}); | ||
}); | ||
it('#should take even chunks', function () { | ||
it('#should take even chunks', function() { | ||
var pref = 'dir1\\*\\dir2\\*'; | ||
resources.forEach(function (res) { | ||
resources.forEach(function(res) { | ||
expect(run(res, pref)).to.equal(alternation(res, pref)); | ||
}); | ||
pref = 'dir1\\[dir]\\dir2\\[dir]'; | ||
resources.forEach(function (res) { | ||
resources.forEach(function(res) { | ||
expect(run(res, pref)).to.equal(alternation(res, pref)); | ||
@@ -191,20 +194,20 @@ }); | ||
describe('take from path (absolute prefix Win style)', function () { | ||
it('#should take odd chunks', function () { | ||
describe('take from path (absolute prefix Win style)', function() { | ||
it('#should take odd chunks', function() { | ||
var pref = '\\*\\dir1\\*\\dir2'; | ||
resources.forEach(function (res) { | ||
resources.forEach(function(res) { | ||
expect(run(res, pref)).to.equal(alternation(res, pref)); | ||
}); | ||
pref = '\\[dir]\\dir1\\[dir]\\dir2'; | ||
resources.forEach(function (res) { | ||
resources.forEach(function(res) { | ||
expect(run(res, pref)).to.equal(alternation(res, pref)); | ||
}); | ||
}); | ||
it('#should take even chunks', function () { | ||
it('#should take even chunks', function() { | ||
var pref = '\\dir1\\*\\dir2\\*'; | ||
resources.forEach(function (res) { | ||
resources.forEach(function(res) { | ||
expect(run(res, pref)).to.equal(alternation(res, pref)); | ||
}); | ||
pref = '\\dir1\\[dir]\\dir2\\[dir]'; | ||
resources.forEach(function (res) { | ||
resources.forEach(function(res) { | ||
expect(run(res, pref)).to.equal(alternation(res, pref)); | ||
@@ -215,9 +218,9 @@ }); | ||
describe('strip dir', function () { | ||
describe('strip dir', function() { | ||
var res = [ | ||
'/Users/myself/Projects/packman/web_modules/angular-ui-bootstrap/template/popover/popover.html', | ||
'W:\\Projects\\packman\\web_modules\\angular-ui-bootstrap\\template\\popover\\popover.html' | ||
'W:\\Projects\\packman\\web_modules\\angular-ui-bootstrap\\template\\popover\\popover.html', | ||
]; | ||
it('#should strip last dir', function () { | ||
it('#should strip last dir', function() { | ||
expect(run(res[0], '*/dir1/*//')).to.equal('web_modules/dir1/template/popover.html'); | ||
@@ -228,7 +231,7 @@ expect(run(res[0], '/*/dir1/*//')).to.equal('/web_modules/dir1/template/popover.html'); | ||
}); | ||
it('#should strip first dir', function () { | ||
it('#should strip first dir', function() { | ||
expect(run(res[0], '//dir1/*/*/')).to.equal('/dir1/template/popover/popover.html'); | ||
expect(run(res[1], '//dir1/*/*/')).to.equal('/dir1/template/popover/popover.html'); | ||
}); | ||
it('#should strip middle and last dir', function () { | ||
it('#should strip middle and last dir', function() { | ||
expect(run(res[0], '*/dir1//*//')).to.equal('packman/dir1/template/popover.html'); | ||
@@ -241,9 +244,9 @@ expect(run(res[0], '/*/dir1//*//')).to.equal('/packman/dir1/template/popover.html'); | ||
describe('strip dir (Win style)', function () { | ||
describe('strip dir (Win style)', function() { | ||
var res = [ | ||
'/Users/myself/Projects/packman/web_modules/angular-ui-bootstrap/template/popover/popover.html', | ||
'W:\\Projects\\packman\\web_modules\\angular-ui-bootstrap\\template\\popover\\popover.html' | ||
'W:\\Projects\\packman\\web_modules\\angular-ui-bootstrap\\template\\popover\\popover.html', | ||
]; | ||
it('#should strip last dir', function () { | ||
it('#should strip last dir', function() { | ||
expect(run(res[0], '*\\dir1\\*\\\\')).to.equal('web_modules/dir1/template/popover.html'); | ||
@@ -254,7 +257,7 @@ expect(run(res[0], '\\*\\dir1\\*\\\\')).to.equal('/web_modules/dir1/template/popover.html'); | ||
}); | ||
it('#should strip first dir', function () { | ||
it('#should strip first dir', function() { | ||
expect(run(res[0], '\\\\dir1\\*\\*\\')).to.equal('/dir1/template/popover/popover.html'); | ||
expect(run(res[1], '\\\\dir1\\*\\*\\')).to.equal('/dir1/template/popover/popover.html'); | ||
}); | ||
it('#should strip middle and last dir', function () { | ||
it('#should strip middle and last dir', function() { | ||
expect(run(res[0], '*\\dir1\\\\*\\\\')).to.equal('packman/dir1/template/popover.html'); | ||
@@ -267,8 +270,8 @@ expect(run(res[0], '\\*\\dir1\\\\*\\\\')).to.equal('/packman/dir1/template/popover.html'); | ||
describe('cross take from path', function () { | ||
describe('cross take from path', function() { | ||
var res = [ | ||
'/Users/myself/Projects/packman/web_modules/angular-ui-bootstrap/template/popover/popover.html', | ||
'W:\\Projects\\packman\\web_modules\\angular-ui-bootstrap\\template\\popover\\popover.html' | ||
'W:\\Projects\\packman\\web_modules\\angular-ui-bootstrap\\template\\popover\\popover.html', | ||
]; | ||
it('#should be same', function () { | ||
it('#should be same', function() { | ||
expect(run(res[0], '/**')).to.equal(res[0]); | ||
@@ -278,9 +281,11 @@ expect(run(res[0], '**')).to.equal(res[0].replace(/^\//, '')); | ||
}); | ||
it('#should strip first chunk', function () { | ||
expect(run(res[0], '//**')).to.equal('/myself/Projects/packman/web_modules/angular-ui-bootstrap/template/popover/popover.html'); | ||
expect(run(res[1], '//**')).to.equal('/Projects/packman/web_modules/angular-ui-bootstrap/template/popover/popover.html'); | ||
it('#should strip first chunk', function() { | ||
expect(run(res[0], '//**')) | ||
.to.equal('/myself/Projects/packman/web_modules/angular-ui-bootstrap/template/popover/popover.html'); | ||
expect(run(res[1], '//**')) | ||
.to.equal('/Projects/packman/web_modules/angular-ui-bootstrap/template/popover/popover.html'); | ||
}); | ||
}); | ||
describe('relative root and full extend', function () { | ||
describe('relative root and full extend', function() { | ||
var prefs = [ | ||
@@ -310,5 +315,5 @@ 'Projects/packman:**', | ||
'Projects\\packman:\\[dirs]', | ||
'Projects\\packman:\\[dirs]\\' | ||
'Projects\\packman:\\[dirs]\\', | ||
]; | ||
var sample = function (res, pref) { | ||
var sample = function(res, pref) { | ||
pref = pref.replace(/\\/g, '/').split(':'); | ||
@@ -321,17 +326,17 @@ res = res.replace(/\\/g, '/').split(pref.shift()).pop(); | ||
return path; | ||
}; | ||
it('#should extend', function () { | ||
prefs.forEach(function (pref) { | ||
resources.forEach(function (res) { | ||
it('#should extend', function() { | ||
prefs.forEach(function(pref) { | ||
resources.forEach(function(res) { | ||
expect(run(res, pref)).to.equal(sample(res, pref)); | ||
}); | ||
}) | ||
}) | ||
}); | ||
}); | ||
}); | ||
describe('absolute root and full extend', function () { | ||
var sample = function (res, pref) { | ||
var root, path; | ||
describe('absolute root and full extend', function() { | ||
var sample = function(res, pref) { | ||
var root; | ||
var path; | ||
@@ -348,3 +353,3 @@ root = pref.replace(/\\/g, '/').split(':'); | ||
it('#should extend', function () { | ||
it('#should extend', function() { | ||
var resources = [ | ||
@@ -366,5 +371,5 @@ '/Users/myself/Projects/packman/web_modules/angular-ui-bootstrap/template/popover/popover.html', | ||
'/Users/myself/Projects/packman:/[dirs]', | ||
'/Users/myself/Projects/packman:/[dirs]/' | ||
].forEach(function (pref) { | ||
resources.forEach(function (res) { | ||
'/Users/myself/Projects/packman:/[dirs]/', | ||
].forEach(function(pref) { | ||
resources.forEach(function(res) { | ||
expect(run(res, pref)).to.equal(sample(res, pref)); | ||
@@ -375,6 +380,6 @@ }); | ||
it('#should extend (Win style)', function () { | ||
it('#should extend (Win style)', function() { | ||
resources = [ | ||
'W:\\Projects\\packman\\web_modules\\angular-ui-bootstrap\\template\\popover\\popover.html', | ||
'W:\\Projects\\packman\\components\\article\\actions\\actions.html' | ||
'W:\\Projects\\packman\\components\\article\\actions\\actions.html', | ||
]; | ||
@@ -393,5 +398,5 @@ [ | ||
'W:\\Projects\\packman:\\[dirs]', | ||
'W:\\Projects\\packman:\\[dirs]\\' | ||
].forEach(function (pref) { | ||
resources.forEach(function (res) { | ||
'W:\\Projects\\packman:\\[dirs]\\', | ||
].forEach(function(pref) { | ||
resources.forEach(function(res) { | ||
expect(run(res, pref)).to.equal(sample(res, pref)); | ||
@@ -405,3 +410,3 @@ }); | ||
var params = { | ||
resource: 'template/popover/popover.html' | ||
resource: 'template/popover/popover.html', | ||
}; | ||
@@ -455,9 +460,9 @@ | ||
describe('various casese', function () { | ||
describe('various casese', function() { | ||
var resources = [ | ||
'/Users/myself/Projects/packman/web_modules/angular-ui-bootstrap/template/popover/popover.html', | ||
'W:\\Projects\\packman\\web_modules\\angular-ui-bootstrap\\template\\popover\\popover.html' | ||
'W:\\Projects\\packman\\web_modules\\angular-ui-bootstrap\\template\\popover\\popover.html', | ||
]; | ||
it('#should extend, replace, strip and take', function () { | ||
resources.forEach(function (res) { | ||
it('#should extend, replace, strip and take', function() { | ||
resources.forEach(function(res) { | ||
expect(run(res, 'packman:**/dir1//*')).to.equal('web_modules/dir1/popover/popover.html'); | ||
@@ -469,9 +474,10 @@ expect(run(res, 'packman:*/dir1/**')).to.equal('web_modules/dir1/template/popover/popover.html'); | ||
}); | ||
it('#should convert second `**` to `*`', function () { | ||
resources.forEach(function (res) { | ||
it('#should convert second `**` to `*`', function() { | ||
resources.forEach(function(res) { | ||
expect(run(res, 'packman:**/dir1//**')).to.equal('web_modules/dir1/popover/popover.html'); | ||
expect(run(res, 'packman:/**/dir1/**')).to.equal('/web_modules/angular-ui-bootstrap/dir1/popover/popover.html'); | ||
expect(run(res, 'packman:/**/dir1/**')) | ||
.to.equal('/web_modules/angular-ui-bootstrap/dir1/popover/popover.html'); | ||
}); | ||
}); | ||
}); | ||
}); | ||
}); |
@@ -21,3 +21,3 @@ var minimizeOptions = JSON.stringify({ | ||
test: /\.html$/, | ||
loader: '../index.js?prefix=grot/[dir]//[dir]//tmpl&module=appModule&name=[name].tpl' + | ||
loader: '../index.js?prefix=grot/[dir]//[dir]//tmpl&module=appModule&name=[name].tpl&-exportId' + | ||
'&minimizeOptions=' + minimizeOptions + | ||
@@ -24,0 +24,0 @@ '&conservativeCollapse' |
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
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
41209
15
843
250
5