Socket
Socket
Sign inDemoInstall

hogan.js

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

hogan.js

A mustache compiler.


Version published
Weekly downloads
606K
increased by6.16%
Maintainers
1
Weekly downloads
 
Created

What is hogan.js?

Hogan.js is a JavaScript templating engine developed by Twitter. It is designed to be a performant and lightweight solution for rendering templates, particularly Mustache templates, on both the client and server sides.

What are hogan.js's main functionalities?

Template Compilation

Hogan.js allows you to compile Mustache templates into JavaScript functions. These functions can then be used to render the templates with given data.

const Hogan = require('hogan.js');
const template = Hogan.compile('Hello, {{name}}!');
const output = template.render({ name: 'World' });
console.log(output); // Output: Hello, World!

Partial Templates

Hogan.js supports partial templates, which allows you to include one template inside another. This is useful for reusing common template fragments.

const Hogan = require('hogan.js');
const mainTemplate = Hogan.compile('Main template: {{>partial}}');
const partialTemplate = Hogan.compile('This is a partial.');
const output = mainTemplate.render({}, { partial: partialTemplate });
console.log(output); // Output: Main template: This is a partial.

Custom Delimiters

Hogan.js allows you to define custom delimiters for your templates. This can be useful if the default Mustache delimiters conflict with other templating languages or syntaxes in your project.

const Hogan = require('hogan.js');
const template = Hogan.compile('Hello, <%name%>!', { delimiters: '<% %>' });
const output = template.render({ name: 'World' });
console.log(output); // Output: Hello, World!

Other packages similar to hogan.js

Keywords

FAQs

Package last updated on 23 Jan 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