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

express-manifest-helpers

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

express-manifest-helpers - npm Package Compare versions

Comparing version 0.4.0 to 0.5.0

test/files-list.spec.js

69

lib/index.js

@@ -8,2 +8,10 @@ 'use strict';

exports.trimTag = trimTag;
exports.getManifest = getManifest;
exports.getSources = getSources;
exports.getStylesheetSources = getStylesheetSources;
exports.getStylesheets = getStylesheets;
exports.getJavascriptSources = getJavascriptSources;
exports.getJavascripts = getJavascripts;
exports.getImageSources = getImageSources;
exports.getImages = getImages;
exports.assetPath = assetPath;

@@ -39,3 +47,3 @@ exports.imageTag = imageTag;

return Object.keys(attrs).map(function (key) {
return '' + key + '="' + attrs[key] + '"';
return key + '="' + attrs[key] + '"';
}).join(' ');

@@ -60,2 +68,47 @@ }

function getManifest() {
return manifest || loadManifest();
}
function getSources() {
manifest = manifest || loadManifest();
return Object.keys(manifest);
}
function getStylesheetSources() {
return getSources().filter(function (file) {
return file.match(/\.css$/);
});
}
function getStylesheets() {
return getStylesheetSources().map(function (source) {
return lookup(source);
});
}
function getJavascriptSources() {
return getSources().filter(function (file) {
return file.match(/\.js$/);
});
}
function getJavascripts() {
return getJavascriptSources().map(function (source) {
return lookup(source);
});
}
function getImageSources() {
return getSources().filter(function (file) {
return file.match(/\.(png|jpe?g|gif|webp|bmp)$/);
});
}
function getImages() {
return getImageSources().map(function (source) {
return lookup(source);
});
}
function assetPath(source) {

@@ -66,3 +119,3 @@ return lookup(source);

function imageTag(source) {
var attrs = arguments[1] === undefined ? {} : arguments[1];
var attrs = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1];

@@ -73,3 +126,3 @@ return trimTag('<img src="' + lookup(source) + '" ' + mapAttrs(attrs) + ' />');

function javascriptTag(source) {
var attrs = arguments[1] === undefined ? {} : arguments[1];
var attrs = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1];

@@ -80,3 +133,3 @@ return trimTag('<script src="' + lookup(source) + '" ' + mapAttrs(attrs) + '></script>');

function stylesheetTag(source) {
var attrs = arguments[1] === undefined ? {} : arguments[1];
var attrs = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1];

@@ -96,2 +149,10 @@ return trimTag('<link rel="stylesheet" href="' + lookup(source) + '" ' + mapAttrs(attrs) + ' />');

return function (req, res, next) {
res.locals.getSources = getSources;
res.locals.getStylesheetSources = getStylesheetSources;
res.locals.getStylesheets = getStylesheets;
res.locals.getJavascriptSources = getJavascriptSources;
res.locals.getJavascripts = getJavascripts;
res.locals.getImageSources = getImageSources;
res.locals.getImages = getImages;
res.locals.getManifest = getManifest;
res.locals.assetPath = assetPath;

@@ -98,0 +159,0 @@ res.locals.imageTag = imageTag;

2

package.json
{
"name": "express-manifest-helpers",
"version": "0.4.0",
"version": "0.5.0",
"description": "View helpers to use with an asset manifest",

@@ -5,0 +5,0 @@ "main": "lib/index.js",

@@ -77,1 +77,17 @@ # Express Manifest Helpers

`stylesheetTag(source, attrs)` - return a link tag for the source provided
`getManifest()` - returns the original manifest file for convenience
`getSources()` - returns a list of sources from the manifest
`getStylesheetSources()` - returns a list of all sources ending with `.css`
`getStylesheets()` - returns a list of all stylesheets and their resolved paths
`getJavascriptSources()` - returns a list of all sources ending with `.js`
`getJavascripts()` - returns a list of all javascripts and their resolved paths
`getImageSources()` - returns a list of all sources ending with `.jpg`, `.jpeg`, `.gif`, `.png`, `.bmp` or `.webp`,
`getImages()` - returns a list of all images and their resolved paths
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