
Research
/Security News
Critical Vulnerability in NestJS Devtools: Localhost RCE via Sandbox Escape
A flawed sandbox in @nestjs/devtools-integration lets attackers run code on your machine via CSRF, leading to full Remote Code Execution (RCE).
gulp-ng-html2js-de
Advanced tools
A Gulp plugin which generates AngularJS modules, which pre-load your HTML code into the $templateCache. This way AngularJS doesn't need to request the actual HTML files anymore.
A plugin for gulp which generates AngularJS modules, which pre-load your HTML code into the $templateCache. This way AngularJS doesn't need to request the actual HTML files anymore.
First, install gulp-ng-html2js
as a development dependency:
npm install --save-dev gulp-ng-html2js
Then, add it to your gulpfile.js
:
var ngHtml2Js = require("gulp-ng-html2js");
gulp.src("./partials/*.html")
.pipe(ngHtml2Js({
moduleName: "MyAwesomePartials",
prefix: "/partials"
}))
.pipe(gulp.dest("./dist/partials"));
The main reason to use this module would be optimization. By pre-loading the HTML files, you can spare requests and
loading time when the files are actually needed. When you are optimizing, you should do it properly. So, we should add
the following plugins: gulp-minify-html
, gulp-uglify
, and gulp-concat
:
var ngHtml2Js = require("gulp-ng-html2js");
var minifyHtml = require("gulp-minify-html");
var concat = require("gulp-concat");
var uglify = require("gulp-uglify");
gulp.src("./partials/*.html")
.pipe(minifyHtml({
empty: true,
spare: true,
quotes: true
}))
.pipe(ngHtml2Js({
moduleName: "MyAwesomePartials",
prefix: "/partials"
}))
.pipe(concat("partials.min.js"))
.pipe(uglify())
.pipe(gulp.dest("./dist/partials"));
This way you end up with 1 single, minified Javascript file, which pre-loads all the (minified) HTML templates.
If you have your modules sorted into directories that match the module name, you could do something like this:
// This picks up files like this:
// partials/date-picker/year.html (as well as month.html, day.html)
// partials/expanded-combo-box/combobox.html
// partials/forms/feedback.html (as well as survey.html, contact.html)
// Returns modules like this:
// datePicker, expandedComboBox, forms
gulp.src("./partials/**/*.html")
.pipe(ngHtml2Js({
moduleName: function (file) {
var pathParts = file.path.split('/');
var folder = pathParts[pathParts.length - 2];
return folder.replace(/-[a-z]/g, function (match) {
return match.substr(1).toUpperCase();
});
}
}))
.pipe(concat("partials.min.js"))
.pipe(gulp.dest('./dist/partials'));
}
Type: String
or Function
The name of the generated AngularJS module. Uses the file url if omitted.
When this is a function, the returned value will be the module name. The function will be passed the vinyl file object so the module name can be determined from the path, content, last access time or any other property. Returning undefined
will fall back to the file url.
Type: Boolean
Whether to attempt to declare a new module (used with options.moduleName). True if omitted.
Set this to false if options.moduleName is already declared.
Type: String
The prefix which should be prepended to the file path to generate the file url.
Type: String
The prefix which should be subtracted from the file path to generate the file url.
Type: Function
A function that allows the generate file url to be manipulated. For example:
function (templateUrl, templateFile) {
return templateUrl.replace('.tpl.html', '.html');
}
Type: String
A custom Lodash template for generating the Javacript code. The template is called with the following params:
Example
{
template: "$templateCache.put('<%= template.url %>', '<%= template.escapedContent %>');"
}
Type: String
The file extension of the generated files. Defaults to .js. Can be used to generate TypeScript files and create a gulp TypeScript - job to convert them. For a working example take a look at angular-systemjs-typescript-boilerplate
Type: String
commonjs
: export the angular module using module.exports =
system
: export the angular module using export default
Note this does not export anything with
declareModule
set totrue
.
Example
{
export: 'commonjs'
}
{
export: 'system'
}
Allows to run plugin outside of the pipe context.
Example
var vinylFile = require('vinyl-file');
var ngHtml2Js = require("gulp-ng-html2js");
vinylFile.read('src/template.html').then(function(vf) {
var options = { moduleName: 'templates' }
var converted = ngHtml2Js.generateModuleDeclaration(vf, options);
});
FAQs
A Gulp plugin which generates AngularJS modules, which pre-load your HTML code into the $templateCache. This way AngularJS doesn't need to request the actual HTML files anymore.
The npm package gulp-ng-html2js-de receives a total of 3 weekly downloads. As such, gulp-ng-html2js-de popularity was classified as not popular.
We found that gulp-ng-html2js-de demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
/Security News
A flawed sandbox in @nestjs/devtools-integration lets attackers run code on your machine via CSRF, leading to full Remote Code Execution (RCE).
Product
Customize license detection with Socket’s new license overlays: gain control, reduce noise, and handle edge cases with precision.
Product
Socket now supports Rust and Cargo, offering package search for all users and experimental SBOM generation for enterprise projects.