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

express-ejs-layouts

Package Overview
Dependencies
Maintainers
2
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

express-ejs-layouts - npm Package Compare versions

Comparing version 1.1.0 to 2.0.0

16

lib/express-layouts.js

@@ -28,3 +28,2 @@ /*jslint sloppy:true indent:2 plusplus:true regexp:true*/

var str = locals.body, regex = /\<script(.|\n)*?\>(.|\n)*?\<\/script\>/g;
locals.script = '';

@@ -37,2 +36,11 @@ if (regex.test(str)) {

function parseStyles(locals) {
var str = locals.body, regex = /(?:\<style(.|\n)*?\>(.|\n)*?\<\/style\>)|(?:\<link(.|\n)*?\>(?:\<\/link\>)?)/g;
if (regex.test(str)) {
locals.body = str.replace(regex, '');
locals.style = str.match(regex).join('\n');
}
}
module.exports = function (req, res, next) {

@@ -77,2 +85,3 @@ var render = res.render;

locals.script = '';
if (options.extractScripts === true || (options.extractScripts === undefined && app.get('layout extractScripts') === true)) {

@@ -82,2 +91,7 @@ parseScripts(locals);

locals.style = '';
if (options.extractStyles === true || (options.extractStyles === undefined && app.get('layout extractStyles') === true)) {
parseStyles(locals);
}
parseContents(locals);

@@ -84,0 +98,0 @@ render.call(self, layout, locals, fn);

2

package.json

@@ -10,3 +10,3 @@ {

],
"version": "1.1.0",
"version": "2.0.0",
"main": "lib/express-layouts.js",

@@ -13,0 +13,0 @@ "dependencies": {},

@@ -77,4 +77,12 @@

req.render('view', { parseScript: true })
req.render('view', { extractScripts: true })
### 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``
## Optional sections

@@ -81,0 +89,0 @@

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