Security News
Fluent Assertions Faces Backlash After Abandoning Open Source Licensing
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
broccoli-handlebars
Advanced tools
Broccoli plugin for compiling handlebars templates that supports using an existing Handlebars instance, partials, helpers, and render context based on the filename.
npm install --save broccoli-handlebars
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); };
});
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)
});
An object of helpers
module.exports = {
firstName: function (str) { return str.split(' ')[0]; }
};
// Hi {{firstName user.fullName}}
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')
});
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'
}
});
FAQs
Compile handlebars templates with helpers and dynamic contexts
We found that broccoli-handlebars demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Security News
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
Research
Security News
Socket researchers uncover the risks of a malicious Python package targeting Discord developers.
Security News
The UK is proposing a bold ban on ransomware payments by public entities to disrupt cybercrime, protect critical services, and lead global cybersecurity efforts.