npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

wintersmith-handlebars

v0.1.1

Published

handlebars plugin for wintersmith

Downloads

1

Readme

Handlebars plugin for Wintersmith

This plugin provides support for using Handlebars for Wintersmith.

This plugin was inspired from wintersmith-hogan.

How to use

Either

  1. Download the repo and copy the wintersmith-handlebars.coffee file into your plugins directory of your wintersmith install.
  2. Add wintersmith-handlebars.coffee to your config.json file.
  3. Starting writing handlebars templates in your templates directory as .html, .hbs or .handlebars files

Or

  1. Install it as a node module via npm install wintersmith-handlebars
  2. Follow steps 2 and 3 above.

Layouts

You can use layouts in wintermsith-handlebars the same way you do in hbs.

Write your layouts as you would normal templates, but make sure they include the variable {{{body}}}. (triple-handlebars prevent the HTML from being treated as plain text)

layout.html

<!DOCTYPE html>
<html>
  <head>
    <title>My Static Site</title>
  </head>
  <body>
    {{{body}}}
  </body>
</html>

Then in your templates, add a {{!< layout.html }} reference at the top of the file:

index.html

{{!< layout.html }}
<p>The index page.</p>

And it will be rendered like so:

<!DOCTYPE html>
<html>
  <head>
    <title>My Static Site</title>
  </head>
  <body>
    <p>The index page.</p>
  </body>
</html>

Partials

This plugin provides support for partials in handlebars.

To start using it, just add a partials directory in your template folder and add partial template files in there.

You can also rename this file to any other fancy name you would like. For eg, if you want it to be bits, you can simply define that in your config.json as follows:

"handlebars": {
  "partialDir": "bits"
}

Helpers

You can add helpers for Handlebars by adding functions in the helper directory. By default, this direcotry is named helpers, and is placed under templates. You can specify custom name for this folder in config.json:

"handlebars": {
  "helperDir": "helpers"
}

Each helper is its own file. The filename will be registered as the helper name.

An example of a helper function:

module.exports = function(stuff) {
  console.log(stuff);
    return;
}

See examples folder for more information.

Note

To use the locals variables in the template, instead of writing {{locals.name}} like in the jade template, simply just write {{name}}. This applies for other variables as well.

See the wiki for a sample 'locals' context being passed to the compiled handlebars template to see what's available and how to call them.

Under development

This plugin is my first attempt at bringing support for handlebars to wintersmith. It is still very new, experimental and under development (read: there might be bugs).

If for some reason it doesn't work for me, please submit an issue and I will hopefully fix it.

Smith away!