chore: disable delete confirmation in VS Code explorer
Disable the confirmation dialog when deleting files in the VS Code explorer to streamline the development workflow and reduce friction during file management operations.
This commit is contained in:
3
website/node_modules/express-ejs-layouts/.travis.yml
generated
vendored
Normal file
3
website/node_modules/express-ejs-layouts/.travis.yml
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
language: node_js
|
||||
node_js:
|
||||
- "node"
|
||||
7
website/node_modules/express-ejs-layouts/LICENSE
generated
vendored
Normal file
7
website/node_modules/express-ejs-layouts/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
Copyright (c) 2012 Igor Soarez <igor@soarez.com>
|
||||
|
||||
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.
|
||||
266
website/node_modules/express-ejs-layouts/Readme.md
generated
vendored
Normal file
266
website/node_modules/express-ejs-layouts/Readme.md
generated
vendored
Normal file
@@ -0,0 +1,266 @@
|
||||
# express-ejs-layouts
|
||||
|
||||
> Layout support for ejs in express
|
||||
|
||||
[](https://badge.fury.io/js/express-ejs-layouts)
|
||||
[](http://travis-ci.org/Soarez/express-ejs-layouts)
|
||||
|
||||
## Installation
|
||||
|
||||
```sh
|
||||
$ npm install express-ejs-layouts
|
||||
```
|
||||
|
||||
## Example
|
||||
|
||||
Check the example folder.
|
||||
|
||||
1. `git clone https://github.com/soarez/express-ejs-layouts.git`
|
||||
2. `cd express-ejs-layouts`
|
||||
3. `npm install`
|
||||
4. `node example`
|
||||
5. Open http://localhost:3000/
|
||||
|
||||
## Usage
|
||||
|
||||
```javascript
|
||||
var express = require('express');
|
||||
var expressLayouts = require('express-ejs-layouts');
|
||||
|
||||
var app = express();
|
||||
|
||||
app.set('view engine', 'ejs');
|
||||
|
||||
app.use(expressLayouts);
|
||||
|
||||
app.get('/', function(req, res) {
|
||||
var locals = {
|
||||
title: 'Page Title',
|
||||
description: 'Page Description',
|
||||
header: 'Page Header'
|
||||
};
|
||||
res.render('the-view', locals);
|
||||
});
|
||||
|
||||
app.listen(3000);
|
||||
```
|
||||
|
||||
|
||||
### `contentFor`
|
||||
|
||||
A view
|
||||
|
||||
```ejs
|
||||
tyler
|
||||
<%- contentFor('foo') %>
|
||||
club
|
||||
<%- contentFor('bar') %>
|
||||
fight
|
||||
```
|
||||
|
||||
With a layout
|
||||
|
||||
```ejs
|
||||
<%-bar%> <%-foo%>
|
||||
<%-body%>
|
||||
```
|
||||
|
||||
Renders
|
||||
|
||||
```
|
||||
fight club
|
||||
tyler
|
||||
```
|
||||
|
||||
|
||||
As another example, consider this view:
|
||||
|
||||
```html
|
||||
foo
|
||||
<%- contentFor('pageSectionA') %>
|
||||
bar
|
||||
<%- contentFor('pageSectionB') %>
|
||||
baz
|
||||
```
|
||||
|
||||
Using it with this layout:
|
||||
|
||||
```html
|
||||
<div class="header"><%- pageSectionA %></div>
|
||||
<div class="body"><%- body %></div>
|
||||
<div class="footer"><%-defineContent('pageSectionB')%></div>
|
||||
```
|
||||
|
||||
Will render:
|
||||
|
||||
```html
|
||||
<div class="header">bar</div>
|
||||
<div class="body">foo</div>
|
||||
<div class="footer">baz</div>
|
||||
```
|
||||
|
||||
Notice that the difference between using `<%- pageSectionA %>` and `<%-defineContent('pageSectionA')%>` is that the former will generate an error if the view doesn't define content for this section.
|
||||
|
||||
|
||||
### Script blocks extraction
|
||||
|
||||
If you like to place all the script blocks at the end, you can do it like this:
|
||||
|
||||
```javascript
|
||||
app.set("layout extractScripts", true)
|
||||
```
|
||||
|
||||
A view
|
||||
|
||||
```html
|
||||
something<script>somejs<script>something
|
||||
```
|
||||
|
||||
With a layout
|
||||
|
||||
```ejs
|
||||
<body>
|
||||
<%- body %>
|
||||
<%- script %>
|
||||
</body>
|
||||
```
|
||||
|
||||
Renders
|
||||
|
||||
```html
|
||||
<body>
|
||||
somethingsomething
|
||||
<script>somejs<script>
|
||||
</body>
|
||||
```
|
||||
|
||||
Enabling invididually:
|
||||
|
||||
```javascript
|
||||
req.render('view', { extractScripts: true })
|
||||
```
|
||||
|
||||
|
||||
When the `"layout extractScripts"` option is activated, scripts defined in views will be extracted (won't be a part of `body`) and will be available for use in the layout through the variable `scripts`.
|
||||
|
||||
Another example:
|
||||
|
||||
This view:
|
||||
|
||||
```html
|
||||
<script src="/b.js" />
|
||||
<div>foo</div>
|
||||
<script src="/a.js" />
|
||||
<div>bar</div>
|
||||
<script src="/c.js" />
|
||||
```
|
||||
|
||||
Used with this layout:
|
||||
|
||||
```html
|
||||
<div class="main">
|
||||
<%- body %>
|
||||
</div>
|
||||
<!-- place the scripts at the end of the html page -->
|
||||
<%- script %>
|
||||
```
|
||||
|
||||
Will render:
|
||||
|
||||
```html
|
||||
<div class="main">
|
||||
<div>foo</div>
|
||||
<div>bar</div>
|
||||
</div>
|
||||
<!-- place the scripts at the end of the html page -->
|
||||
<script src="/b.js" />
|
||||
<script src="/a.js" />
|
||||
<script src="/c.js" />
|
||||
```
|
||||
|
||||
### Style blocks extraction
|
||||
|
||||
Works exactly like script blocks extraction except:
|
||||
|
||||
* Supported tags are `<link rel="stylesheet" …>` and `<style …>`
|
||||
* The option is named `extractStyles`
|
||||
* The template variable in layout is `style`
|
||||
|
||||
### Meta blocks extraction
|
||||
|
||||
Works exactly like script blocks extraction except:
|
||||
|
||||
* Supported tags are `<meta …>` and `<meta …/>`
|
||||
* The option is named `extractMetas`
|
||||
* The template variable in layout is `meta`
|
||||
|
||||
### Set custom default layout
|
||||
|
||||
By default 'layout.ejs' is used. If you want to specify your custom
|
||||
layout (e.g. 'layouts/layout.ejs'), just set `layout` property in
|
||||
express app settings.
|
||||
|
||||
```
|
||||
app.set('layout', 'layouts/layout');
|
||||
```
|
||||
|
||||
### Set custom layout for single render
|
||||
|
||||
Just pass `layout` as render locals object.
|
||||
|
||||
```
|
||||
app.get('/', function(req, res) {
|
||||
res.render('the-view', { layout: 'specific-layout' });
|
||||
});
|
||||
```
|
||||
### Set no layout for single render
|
||||
|
||||
Just pass `layout: false` as render locals object.
|
||||
|
||||
```
|
||||
app.get('/', function(req, res) {
|
||||
res.render('the-view', { layout: false });
|
||||
);
|
||||
```
|
||||
|
||||
## Optional sections
|
||||
|
||||
In a layout, you can have optional sections using `defineContent`:
|
||||
Unspecified section content defaults to `''`.
|
||||
|
||||
```ejs
|
||||
1
|
||||
<%-defineContent('a')%>
|
||||
2
|
||||
<%-defineContent('b')%>
|
||||
3
|
||||
```
|
||||
|
||||
with a view:
|
||||
|
||||
```ejs
|
||||
<%- contentFor('a') %>
|
||||
1.5
|
||||
```
|
||||
|
||||
will render:
|
||||
|
||||
```ejs
|
||||
1
|
||||
1.5
|
||||
2
|
||||
3
|
||||
```
|
||||
|
||||
|
||||
## Running tests
|
||||
|
||||
Clone the repo and run:
|
||||
|
||||
```sh
|
||||
$ npm test
|
||||
```
|
||||
|
||||
## License
|
||||
|
||||
MIT
|
||||
27
website/node_modules/express-ejs-layouts/example/index.js
generated
vendored
Normal file
27
website/node_modules/express-ejs-layouts/example/index.js
generated
vendored
Normal file
@@ -0,0 +1,27 @@
|
||||
var path = require('path');
|
||||
var express = require('express');
|
||||
var expressLayouts = require('..');
|
||||
|
||||
var app = express();
|
||||
|
||||
app.set('views', path.join(__dirname, 'views'));
|
||||
app.set('view engine', 'ejs');
|
||||
app.set('layout extractScripts', true)
|
||||
app.set('layout extractStyles', true)
|
||||
|
||||
app.use(expressLayouts);
|
||||
|
||||
app.get('/', function(req, res) {
|
||||
res.locals = {
|
||||
title: 'Example',
|
||||
message: 'This is a message'
|
||||
};
|
||||
res.render('view', {
|
||||
// additional locals, a custom layout, or other options can be defined here
|
||||
});
|
||||
});
|
||||
|
||||
var port = 3000;
|
||||
app.listen(port, function() {
|
||||
console.log('Listening on http://localhost:%s/', port);
|
||||
});
|
||||
33
website/node_modules/express-ejs-layouts/example/views/layout.ejs
generated
vendored
Normal file
33
website/node_modules/express-ejs-layouts/example/views/layout.ejs
generated
vendored
Normal file
@@ -0,0 +1,33 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title><%= title %></title>
|
||||
|
||||
<% /* Place any styles in the page in this section. */ %>
|
||||
<%- style %>
|
||||
</head>
|
||||
<body>
|
||||
<header>
|
||||
<% /*
|
||||
Define an required placeholder for the header.
|
||||
If a page doesn't define a header, there will be an error when rendering.
|
||||
*/ %>
|
||||
<%- header %>
|
||||
</header>
|
||||
|
||||
<%- body %>
|
||||
|
||||
<footer>
|
||||
<% /*
|
||||
Define an optional placeholder for the footer.
|
||||
If a page doesn't define a footer, this section will simply be empty.
|
||||
*/ %>
|
||||
<%- defineContent('footer') %>
|
||||
</footer>
|
||||
|
||||
<% /* Place any scripts contained in views at the end of the page. */ %>
|
||||
<%- script %>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
37
website/node_modules/express-ejs-layouts/example/views/view.ejs
generated
vendored
Normal file
37
website/node_modules/express-ejs-layouts/example/views/view.ejs
generated
vendored
Normal file
@@ -0,0 +1,37 @@
|
||||
<%- contentFor('header') %>
|
||||
<h1 class="page-title"><%= _locals.title %></h1>
|
||||
|
||||
<%- contentFor('footer') %>
|
||||
<h1>This is the footer</h1>
|
||||
|
||||
<% /*
|
||||
Content for the `body` section should either be the first thing defined
|
||||
in the view, or it has to be declared just like any other section.
|
||||
*/ %>
|
||||
<%- contentFor('body') %>
|
||||
|
||||
This is part of the body.
|
||||
|
||||
<% /*
|
||||
When style extraction is enabled, any custom styles that a page defines, will
|
||||
be extracted out of the content and made available in the specific placeholder.
|
||||
In our example, even though we're defining a <style> within the body, this will
|
||||
be placed, according to our layout, inside of the <head> element.
|
||||
<link> blocks to load external stylesheets are also extracted when the option
|
||||
is enabled.
|
||||
*/ %>
|
||||
|
||||
<style>
|
||||
.page-message { color: blue }
|
||||
</style>
|
||||
|
||||
<% /*
|
||||
Like stylesheets, scripts can also be extracted.
|
||||
This script block will end up at the end of the HTML document.
|
||||
*/ %>
|
||||
<script>
|
||||
// Script content!
|
||||
</script>
|
||||
|
||||
<h1 class="page-message"><%= message %></h1>
|
||||
|
||||
117
website/node_modules/express-ejs-layouts/lib/express-layouts.js
generated
vendored
Normal file
117
website/node_modules/express-ejs-layouts/lib/express-layouts.js
generated
vendored
Normal file
@@ -0,0 +1,117 @@
|
||||
/*jslint sloppy:true indent:2 plusplus:true regexp:true*/
|
||||
|
||||
var contentPattern = '&&<>&&';
|
||||
|
||||
function contentFor(contentName) {
|
||||
return contentPattern + contentName + contentPattern;
|
||||
}
|
||||
|
||||
function parseContents(locals) {
|
||||
var name, i = 1, str = locals.body,
|
||||
regex = new RegExp('\r?\n?' + contentPattern + '.+?' + contentPattern + '\r?\n?', 'g'),
|
||||
split = str.split(regex),
|
||||
matches = str.match(regex);
|
||||
|
||||
locals.body = split[0];
|
||||
|
||||
if (matches !== null) {
|
||||
matches.forEach(function (match) {
|
||||
name = match.split(contentPattern)[1];
|
||||
locals[name] = split[i];
|
||||
i++;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function parseScripts(locals) {
|
||||
var str = locals.body, regex = /\<script[\s\S]*?\>[\s\S]*?\<\/script\>/g;
|
||||
|
||||
if (regex.test(str)) {
|
||||
locals.body = str.replace(regex, '');
|
||||
locals.script = str.match(regex).join('\n');
|
||||
}
|
||||
}
|
||||
|
||||
function parseStyles(locals) {
|
||||
var str = locals.body, regex = /(?:\<style[\s\S]*?\>[\s\S]*?\<\/style\>)|(?:\<link[\s\S]*?\>(?:\<\/link\>)?)/g;
|
||||
|
||||
if (regex.test(str)) {
|
||||
locals.body = str.replace(regex, '');
|
||||
locals.style = str.match(regex).join('\n');
|
||||
}
|
||||
}
|
||||
|
||||
function parseMetas(locals) {
|
||||
var str = locals.body, regex = /\<meta[\s\S]*?\>/g;
|
||||
|
||||
if (regex.test(str)) {
|
||||
locals.body = str.replace(regex, '');
|
||||
locals.meta = str.match(regex).join('\n');
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = function (req, res, next) {
|
||||
if(!res.__render) res.__render = res.render;
|
||||
|
||||
res.render = function (view, options, fn) {
|
||||
var layout, self = this, app = req.app,
|
||||
defaultLayout = app.get('layout');
|
||||
|
||||
options = options || {};
|
||||
if (typeof options === 'function') {
|
||||
fn = options;
|
||||
options = {};
|
||||
}
|
||||
|
||||
if (options.layout === false || ((options.layout || defaultLayout) === false)) {
|
||||
res.__render.call(res, view, options, fn);
|
||||
return;
|
||||
}
|
||||
|
||||
layout = options.layout || res.locals.layout || defaultLayout;
|
||||
if (layout === true || layout === undefined) {
|
||||
layout = 'layout';
|
||||
}
|
||||
|
||||
options.contentFor = contentFor;
|
||||
res.__render.call(res, view, options, function (err, str) {
|
||||
var l, locals;
|
||||
|
||||
if (err) { return fn ? fn(err) : next(err); }
|
||||
|
||||
locals = {
|
||||
body: str,
|
||||
defineContent: function(contentName) { return locals[contentName] || ''; }
|
||||
};
|
||||
for (l in options) {
|
||||
if (options.hasOwnProperty(l) && l !== 'layout' && l !== 'contentFor') {
|
||||
locals[l] = options[l];
|
||||
}
|
||||
}
|
||||
|
||||
if (typeof locals.body !== 'string') {
|
||||
res.__render.call(self, view, locals, fn);
|
||||
return;
|
||||
}
|
||||
|
||||
if (options.extractScripts === true || (options.extractScripts === undefined && app.get('layout extractScripts') === true)) {
|
||||
locals.script = '';
|
||||
parseScripts(locals);
|
||||
}
|
||||
|
||||
if (options.extractStyles === true || (options.extractStyles === undefined && app.get('layout extractStyles') === true)) {
|
||||
locals.style = '';
|
||||
parseStyles(locals);
|
||||
}
|
||||
|
||||
if (options.extractMetas === true || (options.extractMetas === undefined && app.get('layout extractMetas') === true)) {
|
||||
locals.meta = '';
|
||||
parseMetas(locals);
|
||||
}
|
||||
|
||||
parseContents(locals);
|
||||
res.__render.call(self, layout, locals, fn);
|
||||
});
|
||||
};
|
||||
next();
|
||||
};
|
||||
24
website/node_modules/express-ejs-layouts/package.json
generated
vendored
Normal file
24
website/node_modules/express-ejs-layouts/package.json
generated
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
{
|
||||
"author": "Igor Soarez <igorsoarez@gmail.com>",
|
||||
"name": "express-ejs-layouts",
|
||||
"description": "Layout support for ejs in express.",
|
||||
"keywords": [
|
||||
"express",
|
||||
"layout",
|
||||
"ejs"
|
||||
],
|
||||
"version": "2.5.1",
|
||||
"main": "lib/express-layouts.js",
|
||||
"devDependencies": {
|
||||
"ejs": "^2.6.1",
|
||||
"express": "*",
|
||||
"mocha": "*",
|
||||
"should": "*",
|
||||
"supertest": "*"
|
||||
},
|
||||
"optionalDependencies": {},
|
||||
"scripts": {
|
||||
"test": "mocha"
|
||||
},
|
||||
"repository": "git://github.com/Soarez/express-ejs-layouts.git"
|
||||
}
|
||||
Reference in New Issue
Block a user