Uploading the main structure
هذا الالتزام موجود في:
34
node_modules/pug-filters/CHANGELOG.md
مولّد
مباع
Normal file
34
node_modules/pug-filters/CHANGELOG.md
مولّد
مباع
Normal file
@@ -0,0 +1,34 @@
|
||||
# Change log
|
||||
|
||||
## 1.2.4 / 2016-08-23
|
||||
|
||||
- Update to `pug-walk@1.0.0`
|
||||
|
||||
## 1.2.3 / 2016-07-18
|
||||
|
||||
- Fix includes using custom filters
|
||||
|
||||
## 1.2.2 / 2016-06-06
|
||||
|
||||
- Update to `jstransformer@1.0.0`
|
||||
|
||||
## 1.2.1 / 2016-04-27
|
||||
|
||||
- Apply filters to included files as well
|
||||
|
||||
## 1.2.0 / 2016-04-01
|
||||
|
||||
- Add support for specifying per-filter options
|
||||
|
||||
## 1.1.1 / 2015-12-23
|
||||
|
||||
- Update UglifyJS to 2.6.2
|
||||
- Rename to Pug
|
||||
|
||||
## 1.1.0 / 2015-11-14
|
||||
|
||||
- Add support for filtered includes
|
||||
|
||||
## 1.0.0 / 2015-10-08
|
||||
|
||||
- Initial stable release
|
19
node_modules/pug-filters/LICENSE
مولّد
مباع
Normal file
19
node_modules/pug-filters/LICENSE
مولّد
مباع
Normal file
@@ -0,0 +1,19 @@
|
||||
Copyright (c) 2015 Forbes Lindesay
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
42
node_modules/pug-filters/README.md
مولّد
مباع
Normal file
42
node_modules/pug-filters/README.md
مولّد
مباع
Normal file
@@ -0,0 +1,42 @@
|
||||
# pug-filters
|
||||
|
||||
Code for processing filters in pug templates
|
||||
|
||||
[](https://travis-ci.org/pugjs/pug-filters)
|
||||
[](https://david-dm.org/pugjs/pug?path=packages/pug-filters)
|
||||
[](https://david-dm.org/pugjs/pug?path=packages/pug-filters&type=dev)
|
||||
[](https://www.npmjs.org/package/pug-filters)
|
||||
|
||||
## Installation
|
||||
|
||||
npm install pug-filters
|
||||
|
||||
## Usage
|
||||
|
||||
```
|
||||
var filters = require('pug-filters');
|
||||
```
|
||||
|
||||
### `filters.handleFilters(ast, filters)`
|
||||
|
||||
Renders all `Filter` nodes in a Pug AST (`ast`), using user-specified filters (`filters`) or a JSTransformer.
|
||||
|
||||
### `filters.runFilter(name, str[, options[, currentDirectory]])`
|
||||
|
||||
Invokes filter through `jstransformer`.
|
||||
|
||||
This is internally used in `filters.handleFilters`, and is a lower-level interface exclusively for invoking JSTransformer-based filters.
|
||||
|
||||
`name` represents the name of the JSTransformer.
|
||||
|
||||
`str` represents the string to render.
|
||||
|
||||
`currentDirectory` is used when attempting to `require` the transformer module.
|
||||
|
||||
`options` may contain the following properties:
|
||||
|
||||
- `minify` (boolean): whether or not to attempt minifying the result from the transformer. If minification fails, the original result is returned.
|
||||
|
||||
## License
|
||||
|
||||
MIT
|
4
node_modules/pug-filters/index.js
مولّد
مباع
Normal file
4
node_modules/pug-filters/index.js
مولّد
مباع
Normal file
@@ -0,0 +1,4 @@
|
||||
'use strict';
|
||||
|
||||
exports.runFilter = require('./lib/run-filter');
|
||||
exports.handleFilters = require('./lib/handle-filters');
|
144
node_modules/pug-filters/lib/handle-filters.js
مولّد
مباع
Normal file
144
node_modules/pug-filters/lib/handle-filters.js
مولّد
مباع
Normal file
@@ -0,0 +1,144 @@
|
||||
'use strict';
|
||||
|
||||
var dirname = require('path').dirname;
|
||||
var constantinople = require('constantinople');
|
||||
var walk = require('pug-walk');
|
||||
var error = require('pug-error');
|
||||
var runFilter = require('./run-filter');
|
||||
|
||||
module.exports = handleFilters;
|
||||
function handleFilters(ast, filters, options, filterAliases) {
|
||||
options = options || {};
|
||||
walk(
|
||||
ast,
|
||||
function(node) {
|
||||
var dir = node.filename ? dirname(node.filename) : null;
|
||||
if (node.type === 'Filter') {
|
||||
handleNestedFilters(node, filters, options, filterAliases);
|
||||
var text = getBodyAsText(node);
|
||||
var attrs = getAttributes(node, options);
|
||||
attrs.filename = node.filename;
|
||||
node.type = 'Text';
|
||||
node.val = filterWithFallback(node, text, attrs);
|
||||
} else if (node.type === 'RawInclude' && node.filters.length) {
|
||||
var firstFilter = node.filters.pop();
|
||||
var attrs = getAttributes(firstFilter, options);
|
||||
var filename = (attrs.filename = node.file.fullPath);
|
||||
node.type = 'Text';
|
||||
node.val = filterFileWithFallback(
|
||||
firstFilter,
|
||||
filename,
|
||||
node.file,
|
||||
attrs
|
||||
);
|
||||
node.filters
|
||||
.slice()
|
||||
.reverse()
|
||||
.forEach(function(filter) {
|
||||
var attrs = getAttributes(filter, options);
|
||||
attrs.filename = filename;
|
||||
node.val = filterWithFallback(filter, node.val, attrs);
|
||||
});
|
||||
node.filters = undefined;
|
||||
node.file = undefined;
|
||||
}
|
||||
|
||||
function filterWithFallback(filter, text, attrs, funcName) {
|
||||
try {
|
||||
var filterName = getFilterName(filter);
|
||||
if (filters && filters[filterName]) {
|
||||
return filters[filterName](text, attrs);
|
||||
} else {
|
||||
return runFilter(filterName, text, attrs, dir, funcName);
|
||||
}
|
||||
} catch (ex) {
|
||||
if (ex.code === 'UNKNOWN_FILTER') {
|
||||
throw error(ex.code, ex.message, filter);
|
||||
}
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
|
||||
function filterFileWithFallback(filter, filename, file, attrs) {
|
||||
var filterName = getFilterName(filter);
|
||||
if (filters && filters[filterName]) {
|
||||
if (filters[filterName].renderBuffer) {
|
||||
return filters[filterName].renderBuffer(file.raw, attrs);
|
||||
} else {
|
||||
return filters[filterName](file.str, attrs);
|
||||
}
|
||||
} else {
|
||||
return filterWithFallback(filter, filename, attrs, 'renderFile');
|
||||
}
|
||||
}
|
||||
},
|
||||
{includeDependencies: true}
|
||||
);
|
||||
function getFilterName(filter) {
|
||||
var filterName = filter.name;
|
||||
if (filterAliases && filterAliases[filterName]) {
|
||||
filterName = filterAliases[filterName];
|
||||
if (filterAliases[filterName]) {
|
||||
throw error(
|
||||
'FILTER_ALISE_CHAIN',
|
||||
'The filter "' +
|
||||
filter.name +
|
||||
'" is an alias for "' +
|
||||
filterName +
|
||||
'", which is an alias for "' +
|
||||
filterAliases[filterName] +
|
||||
'". Pug does not support chains of filter aliases.',
|
||||
filter
|
||||
);
|
||||
}
|
||||
}
|
||||
return filterName;
|
||||
}
|
||||
return ast;
|
||||
}
|
||||
|
||||
function handleNestedFilters(node, filters, options, filterAliases) {
|
||||
if (node.block.nodes[0] && node.block.nodes[0].type === 'Filter') {
|
||||
node.block.nodes[0] = handleFilters(
|
||||
node.block,
|
||||
filters,
|
||||
options,
|
||||
filterAliases
|
||||
).nodes[0];
|
||||
}
|
||||
}
|
||||
|
||||
function getBodyAsText(node) {
|
||||
return node.block.nodes
|
||||
.map(function(node) {
|
||||
return node.val;
|
||||
})
|
||||
.join('');
|
||||
}
|
||||
|
||||
function getAttributes(node, options) {
|
||||
var attrs = {};
|
||||
node.attrs.forEach(function(attr) {
|
||||
try {
|
||||
attrs[attr.name] =
|
||||
attr.val === true ? true : constantinople.toConstant(attr.val);
|
||||
} catch (ex) {
|
||||
if (/not constant/.test(ex.message)) {
|
||||
throw error(
|
||||
'FILTER_OPTION_NOT_CONSTANT',
|
||||
ex.message +
|
||||
' All filters are rendered compile-time so filter options must be constants.',
|
||||
node
|
||||
);
|
||||
}
|
||||
throw ex;
|
||||
}
|
||||
});
|
||||
var opts = options[node.name] || {};
|
||||
Object.keys(opts).forEach(function(opt) {
|
||||
if (!attrs.hasOwnProperty(opt)) {
|
||||
attrs[opt] = opts[opt];
|
||||
}
|
||||
});
|
||||
return attrs;
|
||||
}
|
47
node_modules/pug-filters/lib/run-filter.js
مولّد
مباع
Normal file
47
node_modules/pug-filters/lib/run-filter.js
مولّد
مباع
Normal file
@@ -0,0 +1,47 @@
|
||||
'use strict';
|
||||
|
||||
var jstransformer = require('jstransformer');
|
||||
var resolve = require('resolve');
|
||||
|
||||
module.exports = filter;
|
||||
|
||||
function getMinifyTransformerName(outputFormat) {
|
||||
switch (outputFormat) {
|
||||
case 'js':
|
||||
return 'uglify-js';
|
||||
case 'css':
|
||||
return 'clean-css';
|
||||
}
|
||||
}
|
||||
|
||||
function filter(name, str, options, currentDirectory, funcName) {
|
||||
funcName = funcName || 'render';
|
||||
var trPath;
|
||||
try {
|
||||
try {
|
||||
trPath = resolve.sync('jstransformer-' + name, {
|
||||
basedir: currentDirectory || process.cwd(),
|
||||
});
|
||||
} catch (ex) {
|
||||
trPath = require.resolve('jstransformer-' + name);
|
||||
}
|
||||
} catch (ex) {
|
||||
var err = new Error('unknown filter ":' + name + '"');
|
||||
err.code = 'UNKNOWN_FILTER';
|
||||
throw err;
|
||||
}
|
||||
var tr = jstransformer(require(trPath));
|
||||
// TODO: we may want to add a way for people to separately specify "locals"
|
||||
var result = tr[funcName](str, options, options).body;
|
||||
if (options && options.minify) {
|
||||
var minifyTranformer = getMinifyTransformerName(tr.outputFormat);
|
||||
if (minifyTranformer) {
|
||||
try {
|
||||
result = filter(minifyTranformer, result, null, currentDirectory);
|
||||
} catch (ex) {
|
||||
// better to fail to minify than output nothing
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
37
node_modules/pug-filters/package.json
مولّد
مباع
Normal file
37
node_modules/pug-filters/package.json
مولّد
مباع
Normal file
@@ -0,0 +1,37 @@
|
||||
{
|
||||
"name": "pug-filters",
|
||||
"version": "4.0.0",
|
||||
"description": "Code for processing filters in pug templates",
|
||||
"keywords": [
|
||||
"pug"
|
||||
],
|
||||
"dependencies": {
|
||||
"constantinople": "^4.0.1",
|
||||
"jstransformer": "1.0.0",
|
||||
"pug-error": "^2.0.0",
|
||||
"pug-walk": "^2.0.0",
|
||||
"resolve": "^1.15.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"jstransformer-cdata": "^1.0.0",
|
||||
"jstransformer-coffee-script": "^1.1.1",
|
||||
"jstransformer-less": "^2.3.0",
|
||||
"jstransformer-markdown-it": "^2.0.0",
|
||||
"jstransformer-stylus": "^1.5.0",
|
||||
"jstransformer-uglify-js": "^1.2.0",
|
||||
"pug-lexer": "^5.0.0",
|
||||
"pug-load": "^3.0.0",
|
||||
"pug-parser": "^6.0.0"
|
||||
},
|
||||
"files": [
|
||||
"lib/handle-filters.js",
|
||||
"lib/run-filter.js",
|
||||
"index.js"
|
||||
],
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/pugjs/pug/tree/master/packages/pug-filters"
|
||||
},
|
||||
"author": "Forbes Lindesay",
|
||||
"license": "MIT"
|
||||
}
|
المرجع في مشكلة جديدة
حظر مستخدم