![Create React App Officially Deprecated Amid React 19 Compatibility Issues](https://cdn.sanity.io/images/cgdhsj6q/production/04fa08cf844d798abc0e1a6391c129363cc7e2ab-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Create React App Officially Deprecated Amid React 19 Compatibility Issues
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.
JsStencil - ExpressJS Javascript Template for Dynamic Webpage generation
ExpressJS Javascript Template for Dynamic Webpage generation
$ npm install jsstencil
<% %>
.<%= %>
or echo
.<%= htmlentities(...) %>
.req
) and response (res
) objects.require
to include NodeJS modules or nested templates....
<% if (user) { %>
<span><%= user.name %></span>
<% } %>
...
A more complex sample that uses express-session
:
<!DOCTYPE html>
<html>
<head>
<% require('./header.jss'); %>
<title>Sample</title>
</head>
<body>
<%
var fs = require('fs');
var fileName = fs.statSync('/tmp/sample-file.txt')
try {
stat = fs.statSync(fileName);
}
catch (e) {
stat = undefined;
}
%>
<div>
<%
if (!req.session.value)
req.session.value = 1;
else
req.session.value++;
%>
<p>Session value: <% echo(req.session.value.toString()); %></p>
<%
if (stat && stat.isFile()) {
%>
<p>sample-file.txt does exist!!</p>
<%
}
%>
</div>
</body>
</html>
<%
done();
%>
IMPORTANT: Because the templates are parsed as javascript files, ensure your code is safe to avoid introducing security issues.
var jstRenderer = require('jsstencil').createRenderer(options);
//...
app.get('*', function(req, res, next) {
jstRenderer(req, res, next);
},
//renderer will pass the request to 'next' if not a .jss file
function(req, res, next) {
//...
}
);
Although
jstRenderer
value can be used as a template view engine, its functionallity will be limited.
done()
All scripts (.jss
) must call done();
or done(err);
when they finish to execute the code.
Given the asynchronous nature of NodeJS, part of the user script may need to wait an asyncronous response, for e.g.: from a database, to render some data so the script must advise the engine when it finishes to do its tasks.
The done
function tells JsStencil that rendering is complete so it can continue executing.
If your code has no asynchronous tasks, simply add the call to done();
at the end. Else call it when your asynchronous callback is called.
If you specify the optional error paremeter, a http status 500 Internal Server Error will be sent to the browser including the details of the error.
root
(string)
Project root for includes with an absolute path (/index.jss).
showErrorDetails
(boolean)
Send details with the 500 Internal Server Error status on JS errors.
fileExt
(string)
File extension to use (default: .jss
)
userData
(object)
A set of values and/or functions to pass to the template. Object keys will appear as global objects in the template.
For example, if you use:
userData: {
mysql: require('mysql'),
intValue: 5
sum: function (a, b) {
return a + b;
}
}
Then you can do something like this:
<%
var a = sum(5, intValue);
%>
When you use require
using a relative path and the file extension matches options.fileExt
(which defaults to .jss
), require
will act as an include command and the content of the file will be inserted at the current script position.
Otherwise require
will have its default NodeJS
behavior.
req
and res
to be unavailable.Licensed under the MIT License (https://opensource.org/licenses/MIT)
JsStencil - Javascript Template for Dynamic Webpage generation Copyright (C) 2017 mxmauro [at] mauroleggieri [dot] com
FAQs
JsStencil - ExpressJS Javascript Template for Dynamic Webpage generation
The npm package jsstencil receives a total of 3 weekly downloads. As such, jsstencil popularity was classified as not popular.
We found that jsstencil 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
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.