Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
co-nested-hbs
Advanced tools
Generator-based Handlebars templates for nested layouts.
koa-hbs is really great, but doesn't support nested layouts. Adding nested layouts to koa-hbs would unfortunately be a complete rewrite.
co-nested-hbs supports layouts, helpers, and partials.
$ npm install co-nested-hbs
views/overall_layout.hbs
<html>
<head>
<title>{{title}}</title>
</head>
<body>
{{{body}}}
</body>
</html>
views/simple_theme.hbs
<header>
Simple Theme!
</header>
<div class="simple_theme">
{{{body}}}
</div>
<footer>
Footer!
</footer>
views/home.hbs
<p>Welcome {{name}}!<p>
var r = require('rethinkdb');
var co = require('co');
var view = require('co-nested-hbs');
co(function *() {
var html = yield view.renderAll([
['home', {name: 'Bob'}],
['simple_theme'],
['overall_layout', {title: 'Hello World!'}]
]);
})();
html output would be:
<html>
<head>
<title>Hello World!</title>
</head>
<body>
<header>
Simple Theme!
</header>
<div class="simple_theme">
<p>Welcome Bob!<p>
</div>
<footer>
Footer!
</footer>
</body>
</html>
Partials are automatically registered if their filename matches _*.hbs
, directory is ignored.
function *() {
var view = require('co-nested-hbs')('view_path/goes/here');
// single template rendering
var html = yield view.render('template', {local: 'variable'});
// register helper
view.registerHelper('link-to', function(url, text) {
return "<a href='" + this.url + "'>" + this.text + "</a>";
});
// render the following templates in a chain, building the 'nest'
var html = yield view.renderAll([
['first_render', {name: 'Bob'}],
['second_render'], // {{{body}}} here will refer to the first_render html output
['third_render', {title: 'Hello World!'}] // {{{body}}} here will refer to the second_render html output. voila, nesting.
]);
}
MIT
FAQs
Generator-based Handlebars templates for nested layouts.
The npm package co-nested-hbs receives a total of 1 weekly downloads. As such, co-nested-hbs popularity was classified as not popular.
We found that co-nested-hbs demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 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.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.