![Deno 2.2 Improves Dependency Management and Expands Node.js Compatibility](https://cdn.sanity.io/images/cgdhsj6q/production/97774ea8c88cc8f4bed2766c31994ebc38116948-1664x1366.png?w=400&fit=max&auto=format)
Security News
Deno 2.2 Improves Dependency Management and Expands Node.js Compatibility
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
squirrelly
Advanced tools
Squirrelly is an easy-to-use ExpressJS Template engine that includes basic conditional statements, passing in options to HTML, and even passing in options to inline JavaScript for advanced conditionals!
__express
functionsquirrelly
(npm install squirrelly --save
)index.sqrl
file (that's explained below, but basically you just put options between double brackets)
const express = require('express')//Require express
const app = express()
app.set('views', 'tests/views') //specify views directory (where your sqrl files are)
app.engine('sqrl', require('squirrelly').__express);//Set the template engine to squirrelly, and make it use .sqrl files. If you don't do this, you'll have to use the file extension .squirrelly
app.set('view engine', 'sqrl'); (use squirrelly as a template engine)
app.get('/', function (req, res) {//When a request is made to the server
res.render('index', { title: 'Hey', message: 'Hello there!', birthday: 'today', truth: true, untruth: false})//Render index.sqrl, with options
})
app.listen(3000, function () {//Start the server
console.log('Should be rendering on port 3000...')
})
To use squirrelly, instead of creating an HTML file, create a .sqrl
file. (This will only work if you inlude the following code:
app.engine('sqrl', require('squirrelly').__express);
Otherwise, you can name your files with the .squirrelly
extension. Inside these files, to pass in an option, just put it inside of double brackets. For example, if the options passed to the squirrelly file are { title: 'why you should use squirrelly', reason: 'it's awesome'}
, your .sqrl
file could look like this:
<!DOCTYPE html>
<html>
<head>
<title>{{title}}</title> //Evaluates to <title>why you should use squirrelly</title>
</head>
<body>
<p>Because {{reason}}</p> //Evaluates to <p>Because it's awesome</p>
</body>
</html>
Right now, squirrelly only has basic functionality with conditionals (though it's under active development.) But remember, squirrelly can parse anything, even content of script
tags. We recommend using squirrelly inside script tags for advanced logic. A very basic example is shown below:
<script>
var userInfo = {{{userInfo}}};
if (userInfo !== null && userInfo !== undefined) {
document.getElementById("userInfo").innerHTML = {{{userInfo}}};
}
</script>
Conditionals have the same simplicity as just regularly passing in options. Currently, Squirrelly just supports true and false conditionals, but more options are expected to come very soon.
A basic Squirrelly conditional follows the following syntax:
{(conditional statement){
HTML that displays if the conditional passes
}*}
To test if an option is true, pass in the desired option without anything else.
{(truth){
<p>truth = true!</p>
}*}
To test if an option is false, pass in the option with an exclamation point in front of it.
{(!untruth){
<p>untruth = false!</p>
}*}
Squirrelly is still under very active development, and all contributors are welcome. Feel free to fork, clone, and mess around! Then, contact me, create an issue, or send a pull request at Squirrelly's Github Repo.
Beginners are welcome! We welcome all contributors, no matter what skill level.
FAQs
Lightweight, fast, and powerful JS template engine. Supports helpers, filters, template inheritance
The npm package squirrelly receives a total of 14,674 weekly downloads. As such, squirrelly popularity was classified as popular.
We found that squirrelly demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers 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
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
Security News
React's CRA deprecation announcement sparked community criticism over framework recommendations, leading to quick updates acknowledging build tools like Vite as valid alternatives.
Security News
Ransomware payment rates hit an all-time low in 2024 as law enforcement crackdowns, stronger defenses, and shifting policies make attacks riskier and less profitable.