Security News
Input Validation Vulnerabilities Dominate MITRE's 2024 CWE Top 25 List
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
gulp-template-compile-es6
Advanced tools
Gulp task to precompile lodash templates into ES6 exported variables
Compile Lo-Dash templates (should work with Underscore templates too).
This plugin is heavily inspired by Emanuele Ingrosso.
I've written another plugin which only exports templates' string and can also wrap them with a compilation function
Install with npm
npm i --save-dev gulp-template-compile-es6
gulpfile.js
var gulp = require('gulp');
var template = require('gulp-template-compile-es6');
var concat = require('gulp-concat');
gulp.task('default', function () {
gulp.src('src/*.html')
.pipe(template({
templateSettings : {
variable : 'data'
}
})) // pass any settings here
.pipe(concat('templates.js'))
.pipe(gulp.dest('dist'));
});
templates.js
:(for 2 simple html files a.html
& b.html
which contains the string "foo" & "bar")
export var a = function(data) {
var __t, __p = '';
__p += 'foo';
return __p;
}
export var b = function(data) {
var __t, __p = '';
__p += 'bar';
return __p;
}
See the Lo-Dash _.template
docs.
Type: Object
Type: Function
Default: Relative template path. Example: templates/list.html
You can override the default behavior by supplying a function which gets the current File object and is expected to return the name.
Example:
{
name: function (file) {
return 'tpl-' + file.relative;
}
}
Type: String
Default: 'JST'
The namespace in which the precompiled templates will be assigned. Starting from version 1.0 you could also provide a dotted namespace that will be correctly handled, thanks to fhawkes. For example 'custom.namespace' will result in window['custom']['namespace']
.
Type: Object
Default: null
MIT © Yair Even-Or
FAQs
Gulp task to precompile lodash templates into ES6 exported variables
The npm package gulp-template-compile-es6 receives a total of 0 weekly downloads. As such, gulp-template-compile-es6 popularity was classified as not popular.
We found that gulp-template-compile-es6 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.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.
Research
Security News
A threat actor's playbook for exploiting the npm ecosystem was exposed on the dark web, detailing how to build a blockchain-powered botnet.