Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Socket
Sign inDemoInstall

hbs

Package Overview
Dependencies
Maintainers
2
Versions
49
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

hbs

Express.js template engine plugin for Handlebars


Version published
Weekly downloads
142K
decreased by-5.96%
Maintainers
2
Weekly downloads
 
Created

What is hbs?

The hbs package is a Handlebars view engine for Express. It allows you to use Handlebars templates to render HTML pages in your Express applications.

What are hbs's main functionalities?

Registering Partials

This feature allows you to register partials, which are reusable components that can be included in other templates. The code sample demonstrates how to register partials located in the 'views/partials' directory.

const hbs = require('hbs');
hbs.registerPartials(__dirname + '/views/partials');

Using Helpers

Helpers are functions that can be used within your templates to perform specific tasks. The code sample shows how to register a helper named 'scream' that converts text to uppercase.

const hbs = require('hbs');
hbs.registerHelper('scream', function(text) {
  return text.toUpperCase();
});

Rendering Views

This feature allows you to render views using Handlebars templates. The code sample demonstrates setting up an Express application to use hbs as the view engine and rendering an 'index' view with a title.

const express = require('express');
const hbs = require('hbs');
const app = express();
app.set('view engine', 'hbs');
app.get('/', (req, res) => {
  res.render('index', { title: 'Home Page' });
});
app.listen(3000);

Other packages similar to hbs

FAQs

Package last updated on 24 May 2012

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc