
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).
Pre-compiled EJS with inheritance, block and file support that works both in the client and on the server
PEJS is pre-compiled EJS with a inheritance, blocks and file support that works both in the client and on the server. It's available through npm:
npm install pejs
PEJS is easy to use:
var pejs = require('pejs');
var views = pejs(); // pass in {compress:true} to get compressed output
views.render('./example.ejs', function(err, result) {
// renders example.ejs into a string
console.log(result);
});
views.parse('./example.ejs', function(err, src) {
// parses the template and compiles it down to portable js
// this means it works in the client!
console.log(src);
});
PEJS has an internal cache of parsed templates which means that when you render a template twice it will only parse it once.
It also makes sure to clear this cache if the template has changed in anyway on the disk
The pejs()
init function supports the following options:
compress
: Compress the template output. Default: false
basedir
: Base directory for template resolution. Default: cwd
watch
: Watch templates for changes. Default: true
PEJS uses a similar file/module resolution as node.js.
views.render('./file')
: pejs will look for file.pejs
, file.ejs
, file.html
, file/index.pejs
, file/index.ejs
or file/index.html
.views.render('template')
: pejs will look for for template
in in the nearest views
folder using the same scheme as above.This is almost exactly the same as node does with it's node_modules
resolution.
PEJS templates has your usual EJS syntax with <%
and %>
. Read more about EJS here
<% var a = 42; %>
<%- data %>
<%= data %>
PEJS expands the original EJS syntax by letting you declare blocks using the <%{
syntax.
A block is basically a partial template that optionally can be loaded from a file.
<%{{ blockName }}%>
<%{ './filename.html' }%>
<%{ blockName %>hello block<%} %>
In general all block can be loaded from a file instead of being defined inline by providing a filename:
<%{{ myBlock './example.ejs' }}%>
<%{ myOverrideBlock 'example.ejs' }%>
If you want include a block using a different set of locals than in you current scope you pass these as the last argument to the block.
<%{{ myBlock {newLocalsArg:oldLocalsArg} }}%>
<%{ './example.ejs', newLocalsHere }%>
All filepaths above are subject to the same path resolution as decribed in the previous section.
Using blocks it's easy to implement template inheritance.
Just declare a base.html
with some anchored blocks:
<body>
Hello i am base
<%{{ content }}%>
</body>
Then a child.html
that renders base.html
<%{ './base.html' }%>
<%{ content %>
i am inserted in base
<%} %>
To render the example just render child.html
pejs.render('./child.html', function(err, result) {
console.log(result);
});
The above outputs:
<body>
Hello i am base
i am inserted in base
</body>
MIT
FAQs
Pre-compiled EJS with inheritance, block and file support that works both in the client and on the server
The npm package pejs receives a total of 41 weekly downloads. As such, pejs popularity was classified as not popular.
We found that pejs 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.