
Security News
Axios Supply Chain Attack Reaches OpenAI macOS Signing Pipeline, Forces Certificate Rotation
OpenAI rotated macOS signing certificates after a malicious Axios package reached its CI pipeline in a broader software supply chain attack.

hogan.js precompiler for client side vanillaJS templates
Inspired by templatizer and built on top of hogan.js
Hoganizer precompiles mustache templates in to vanillaJS javascript functions so they render blazingly fast on the client side. This renders your app way faster because:
When you are doing client side templating but want to speed up your template parsing on the frontend, Hoganizer is for you! You can use Hoganizer to compile all templates and output to a file or as a string. If you are writing mustache templates which you want to render on the backend (using express for example) this is not for you.
var Hoganizer = require('hoganizer');
var hoganizer = new Hoganizer({
templateDir: './templates',
extension: '.mustache',
writeLocation: './templates.js'
});
// Compile all mustache templates in `./templates` and write
// them into frontend js file to `./templates.js`.
hoganizer.write();
// Compile but save the script as a string
var vanillaJS = hoganizer.precompile();
// Grab the latest compiled version
var vanillaJS = hoganizer.getCached();
If you are working on frontend javascript website you can put all mustache templates in a templates folder and use Hoganizer to precompile the whole folder into a single vanillaJS file.
Create a file called home.mustache inside templates:
I am <em>{{name}}</em>, I like {{hobby}}!
<script src='templates.js'></script>
var NameOfTemplate = 'home';
var parameters = {name: 'Hulk', hobby: 'wrestling' };
var renderedTemplate = templates[NameOfTemplate].render(parameters);
// -> 'I am <em>Hulk</em>, I like Wrestling!';
$('body').html(renderedTemplate);
Run hoganizer.write(); to create compiled functions and save them into templates.js, a static file which you can serve through a normal webserver.
To squeeze out the best performance, I recommend JS minifying the resulting templates.js (and for example concatenating it with the rest of your frontend JS) as well as HTML minifying the mustache files before they are written to vanillaJS by the write method (because after this process JS minifiers do not touch compiled JS strings).
Warning: don't use the precompile & write methods on a in production running nodejs webserver. They use sync fs methods and thus block your whole node server!
You can route your dev environment through an express server for example and you can serve all static files normally but generate templates on the fly for requests to templates.js. This way you can keep editting the templates in the templates folder and on every refresh you get the latest version served.
var express = require('express');
var app = express();
app.configure(function(){
app.use(app.router);
app.use(express.errorHandler({dumpExceptions:true, showStack:true}));
// serve all files out of the folder `static`
app.use(express.static(__dirname + '/static'));
});
var port = 1337;
app.listen(port);
// browse to localhost:1337
And you can catch all calls to /templates.js and serve a fresh version of your compiled templates.
var Hoganizer = require('hoganizer');
var hoganizer = new Hoganizer();
app.get("/templates.js", function(req, res) {
res.contentType(".js");
res.send(hoganizer.precompile());
});
FAQs
A hogan.js precompiler for client side vanillaJS templates
The npm package hoganizer receives a total of 4 weekly downloads. As such, hoganizer popularity was classified as not popular.
We found that hoganizer 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
OpenAI rotated macOS signing certificates after a malicious Axios package reached its CI pipeline in a broader software supply chain attack.

Security News
Open source is under attack because of how much value it creates. It has been the foundation of every major software innovation for the last three decades. This is not the time to walk away from it.

Security News
Socket CEO Feross Aboukhadijeh breaks down how North Korea hijacked Axios and what it means for the future of software supply chain security.