Research
Security News
Kill Switch Hidden in npm Packages Typosquatting Chalk and Chokidar
Socket researchers found several malicious npm packages typosquatting Chalk and Chokidar, targeting Node.js developers with kill switches and data theft.
breezeblock
Advanced tools
An experimental templating language for JS that can compile directly to DOM.
Compatible with all modern browsers and IE9+.
npm install breezeblock --save
Using Breezeblock in Express:
var express = require('express');
var app = express();
app.engine('brz', require('breezeblock').renderTemplate);
app.set('view engine', 'brz');
app.get('/', function(req, res) {
// This will render myTemplate.brz
res.render('myTemplate', {foo: 'bar', my: 'variables'});
});
Using Breezeblock elsewhere:
var breezeblock = require('breezeblock');
// On the fly
breezeblock.renderTemplate(
'templates/myTemplate.brz', // Path to template
{my: 'variables'}, // Data to render template with
function(err, output) {
console.log(output);
}
)
// Compiled
var compiledTemplate = breezeblock.compileTemplate('templates/myTemplate.brz');
console.log(compiledTemplate({my: 'variables'}));
Compiling your templates:
breeze-compile path/to/template.brz
BreezeBlock templates can compile to a number of different formats:
The HTML format simply outputs a string of markup when the template is rendered. The Precompiled HTML generator format outputs the template as JavaScript, preventing unnecessary overhead from parsing the template and traversing its AST. This feature is implemented in many templating engines. The DOM generator is unique: the template is output as JavaScript that directly generates DOM using createElement
and createTextNode
.
<!-- This: -->
<img src={{foo}}>
<!-- becomes this: -->
<script>
function template(document, elem, scope) {
var elem1 = document.createElement("img");
elem1.setAttribute("src".toLowerCase(), scope["foo"]);
elem.appendChild(elem1);
elem.appendChild(document.createTextNode("\n"));
}
</script>
innerHTML
is never used and markup is never concatenated with user-provided data, there is virtually no risk of XSS.document
object to the DOM generation function.Write HTML as you normally would. Self-closing tags that are not void elements must use a closing slash (<foo />
).
<div>
Text nodes can be included inline
<br>
<!-- HTML comments are welcome -->
<b class="really-bold">Mix and match tags</b>
<my-custom-element />
</div>
Attribute names and values may be variable:
<div {{foo}}="bar"></div>
<div data-foo={{bar}}></div>
<!--
`fieldChecked` and `fieldReadonly` should contain "checked" and "readonly respectively"
-->
<input type="text" {{fieldChecked}} {{fieldReadonly}}>
<!-- Attributes may be conditional -->
<img src="foo.jpg" alt="" {% if imageTitle %}title={{imageTitle}}{%/ if %}>
<input type="checkbox" {% if checkboxChecked %}checked{%/ if %}>
Node contents can be variable:
<div>Here is my {{value}}</div>
<aside>{{value}}</aside>
Expressions can use dot notation and subscripts:
<img src={{images[index].src}} alt={{images[index]["alt"]}}>
<img src={{images[0].src}} alt={{images[0]["alt"]}}>
{% loop ... %}
{{{foo}}}
)FAQs
A flexible JS-based templating engine
The npm package breezeblock receives a total of 0 weekly downloads. As such, breezeblock popularity was classified as not popular.
We found that breezeblock 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
Socket researchers found several malicious npm packages typosquatting Chalk and Chokidar, targeting Node.js developers with kill switches and data theft.
Security News
pnpm 10 blocks lifecycle scripts by default to improve security, addressing supply chain attack risks but sparking debate over compatibility and workflow changes.
Product
Socket now supports uv.lock files to ensure consistent, secure dependency resolution for Python projects and enhance supply chain security.