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

hogan.js

Package Overview
Dependencies
Maintainers
2
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.

  • 2.0.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
655K
increased by16.15%
Maintainers
2
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 13 Mar 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