Socket
Socket
Sign inDemoInstall

@behance/hogan-compiler

Package Overview
Dependencies
Maintainers
14
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@behance/hogan-compiler

Behance Hogan Compiler


Version published
Weekly downloads
1
Maintainers
14
Weekly downloads
 
Created
Source

Behance Hogan Compiler Build Status NPM version

This Browser / Node.js library is a helper for loading mustache templates via Hogan.js.

Features

  • caching & asynchronous loading
  • retrieval and resolution of partials
  • retrieve the files any way you like via the driver (e.g, XHR in the browser and fs in Node.js)

Usage

const hoganCompiler = require('@behance/hogan-compiler');

// Bring Your Own Driver
const fsDriver = require('@behance/hogan-compiler/src/drivers/fs');
const templatesPath = '/tmp';

const compiler = hoganCompiler.create(fsDriver, templatesPath/*, options */);

// When using `options.isCached`, you may want to populate the cache before making `.compile()` calls
compiler.populateCache()
.then(() => console.log('Cache has been populated'));

// provide just the name, no need for the template dir or the extension
compiler.compile('my_template')
.then((template) => {
  const renderedString = template.render({ name: 'Mary' });
  console.log(renderedString);
});

Create Arguments:
  • driver - will be used to read files. All methods must return a Promise. See src/drivers/fs for an example.
  • templatesPath - absolute path to the templates
  • options.extension - defaults to mustache (e.g., template.mustache)
  • options.isCached - cache compiled templates in the created instance
HoganCompilerOptions:
  • asString - return the compiled template as a string. This feature is used by hulk to produce strings containing pre-compiled templates.
  • sectionTags - allow custom tags that require opening and closing tags, and treat them as though they were section tags.
  • delimiters - A string that overrides the default delimiters. Example: "<% %>"
  • disableLambda - isables the higher-order sections / lambda-replace features of Mustache.

For more details see Hogan Compilation options.

License

Apache-2.0

Keywords

FAQs

Package last updated on 23 Jun 2017

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