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

hbsrender

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

hbsrender

Render Handlebars templates and embed partials from the command line

  • 1.0.9
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

HbsRender v1.0.9

A CLI tool to render Handlebars templates with partials

Installation

npm i hbsrender --save

Why?

The standard Handlebars CLI interface doesn't allow you to include sub-templates (template parts) in templates to be rendered on the server.

Features

This module has a single purpose: to provide a CLI interface to render Handlebars templates server-side. It does that by giving you parameters to specify paths to template parts and to a JSON file containing the context.

Note: the output of this tool is not a compiled Handlebars template. The template is compiled in-memory and immediately used with the context data to generate a render.

Usage

./node_modules/.bin/hbsrender [options]

Options:

-h, --help                 output usage information
-V, --version              output the version number
-t, --template <template>  tempate to render
-p, --partial <partial>    partial to make available to the template
-c, --context <context>    JSON file with data to be made available to the template

You can use any number of "-p" parameters to specify as many template parts as you need. The value of the "-p" parameter must be specified in the format partial-name:path-to-file.

Example

./node_modules/.bin/hbsrender -t main_template.hbs -c ./context.json -p part1:parts/part1.hbs -p part2:parts/part2.hbs

This will render the main_template.hbs to standard output, pulling variables for the rendering from context.json.

To render to a file you can do:

./node_modules/.bin/hbsrender [options] > output.html

In this example, inside main_template.hbs you can refer to the partials "part1" and "part2" respectively using {{#> part1}} and {{#> part2}}.

You can also provide default replacementes for a partial (should it be not provided on the command line) using the following snippet:

{{#> part1}}
	
	...fallback content here...

{{/part1}}

Licensing

This package is released under the MIT License

FAQs

Package last updated on 22 Dec 2016

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