Express addition
This commit is contained in:
34
node_modules/pug-filters/CHANGELOG.md
generated
vendored
Normal file
34
node_modules/pug-filters/CHANGELOG.md
generated
vendored
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
generated
vendored
Normal file
19
node_modules/pug-filters/LICENSE
generated
vendored
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
generated
vendored
Normal file
42
node_modules/pug-filters/README.md
generated
vendored
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
generated
vendored
Normal file
4
node_modules/pug-filters/index.js
generated
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
'use strict';
|
||||
|
||||
exports.runFilter = require('./lib/run-filter');
|
||||
exports.handleFilters = require('./lib/handle-filters');
|
||||
112
node_modules/pug-filters/lib/handle-filters.js
generated
vendored
Normal file
112
node_modules/pug-filters/lib/handle-filters.js
generated
vendored
Normal file
@@ -0,0 +1,112 @@
|
||||
'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;
|
||||
var str = node.file.str;
|
||||
node.type = 'Text';
|
||||
node.val = filterFileWithFallback(firstFilter, filename, str, 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, text, attrs) {
|
||||
var filterName = getFilterName(filter);
|
||||
if (filters && filters[filterName]) {
|
||||
return filters[filterName](text, 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;
|
||||
}
|
||||
41
node_modules/pug-filters/lib/run-filter.js
generated
vendored
Normal file
41
node_modules/pug-filters/lib/run-filter.js
generated
vendored
Normal file
@@ -0,0 +1,41 @@
|
||||
'use strict';
|
||||
|
||||
var jstransformer = require('jstransformer');
|
||||
var uglify = require('uglify-js');
|
||||
var CleanCSS = require('clean-css');
|
||||
var resolve = require('resolve');
|
||||
|
||||
module.exports = filter;
|
||||
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) {
|
||||
try {
|
||||
switch (tr.outputFormat) {
|
||||
case 'js':
|
||||
result = uglify.minify(result, {fromString: true}).code;
|
||||
break;
|
||||
case 'css':
|
||||
result = new CleanCSS().minify(result).styles;
|
||||
break;
|
||||
}
|
||||
} catch (ex) {
|
||||
// better to fail to minify than output nothing
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
68
node_modules/pug-filters/package.json
generated
vendored
Normal file
68
node_modules/pug-filters/package.json
generated
vendored
Normal file
@@ -0,0 +1,68 @@
|
||||
{
|
||||
"_from": "pug-filters@^3.1.1",
|
||||
"_id": "pug-filters@3.1.1",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha512-lFfjNyGEyVWC4BwX0WyvkoWLapI5xHSM3xZJFUhx4JM4XyyRdO8Aucc6pCygnqV2uSgJFaJWW3Ft1wCWSoQkQg==",
|
||||
"_location": "/pug-filters",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "range",
|
||||
"registry": true,
|
||||
"raw": "pug-filters@^3.1.1",
|
||||
"name": "pug-filters",
|
||||
"escapedName": "pug-filters",
|
||||
"rawSpec": "^3.1.1",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "^3.1.1"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/pug"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/pug-filters/-/pug-filters-3.1.1.tgz",
|
||||
"_shasum": "ab2cc82db9eeccf578bda89130e252a0db026aa7",
|
||||
"_spec": "pug-filters@^3.1.1",
|
||||
"_where": "D:\\SOURCE\\gittesting\\node_modules\\pug",
|
||||
"author": {
|
||||
"name": "Forbes Lindesay"
|
||||
},
|
||||
"bundleDependencies": false,
|
||||
"dependencies": {
|
||||
"clean-css": "^4.1.11",
|
||||
"constantinople": "^3.0.1",
|
||||
"jstransformer": "1.0.0",
|
||||
"pug-error": "^1.3.3",
|
||||
"pug-walk": "^1.1.8",
|
||||
"resolve": "^1.1.6",
|
||||
"uglify-js": "^2.6.1"
|
||||
},
|
||||
"deprecated": false,
|
||||
"description": "Code for processing filters in pug templates",
|
||||
"devDependencies": {
|
||||
"get-repo": "^1.0.0",
|
||||
"jstransformer-cdata": "^1.0.0",
|
||||
"jstransformer-coffee-script": "^1.0.0",
|
||||
"jstransformer-less": "^2.1.0",
|
||||
"jstransformer-markdown-it": "^1.0.0",
|
||||
"jstransformer-stylus": "^1.0.0",
|
||||
"jstransformer-uglify-js": "^1.1.1",
|
||||
"pug-lexer": "^4.1.0",
|
||||
"pug-load": "^2.0.12",
|
||||
"pug-parser": "^5.0.1"
|
||||
},
|
||||
"files": [
|
||||
"lib/handle-filters.js",
|
||||
"lib/run-filter.js",
|
||||
"index.js"
|
||||
],
|
||||
"gitHead": "1bdf628a70fda7a0d840c52f3abce54b1c6b0130",
|
||||
"keywords": [
|
||||
"pug"
|
||||
],
|
||||
"license": "MIT",
|
||||
"name": "pug-filters",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/pugjs/pug/tree/master/packages/pug-filters"
|
||||
},
|
||||
"version": "3.1.1"
|
||||
}
|
||||
Reference in New Issue
Block a user