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

broccoli-handlebars

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

broccoli-handlebars

Compile handlebars templates with helpers and dynamic contexts

  • 0.0.1
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

Broccoli Handlebars

Broccoli plugin for compiling handlebars templates that supports using an existing Handlebars instance, partials, helpers, and render context based on the filename.

Install

npm install --save broccoli-handlebars

Example

var Handlebars = require('handlebars');
var broccoliHandlebars = require('broccoli-handlebars');
var helpers = require('./my-helpers-object');
var dataForFile = require('./get-view-data');

var tree = broccoliHandlebars(tree, {
  helpers: helpers
, handlebars: Handlebars
, partials: 'partials-path'
, context: function (filename) { return dataForFile(filename); };
});

Options

context (optional)

A function or object used as the render context. The function is passed the filename allowing for dynamic contexts.

function RenderContext () {}

RenderContext.prototype.render = function (filename) {
  return {
    title: filename.toUpperCase()
  };
};

var renderContext = new RenderContext();

var tree = broccoliHandlebars(tree, {
  // An object that is the same for each file
  context: { title: 'Foo' }
  // or renter data based on the file name
  context: renderContext.render.bind(renderContext)
});
helpers (optional)

An object of helpers

module.exports = {
  firstName: function (str) { return str.split(' ')[0]; }
};

// Hi {{firstName user.fullName}}
handelbars (optional)

A Handlebars instance. Useful if you need to make sure you are using a specific version or have already registerd partials/helpers.

var tree = broccoliHandlebars(tree, {
  handlebars: require('handlebars')
});
partials (optional)

Either a string that is the path to partials or an object where the key is the name of the partial and the value is the actual partial string.

var tree = broccoliHandlebars(tree, {
  partials: 'path/to/partials'
  // or
  partials: {
    'header': '<header>foo</header'
  , 'users/card': '<div>bar</div'
  }
});

Keywords

FAQs

Package last updated on 13 Jul 2014

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