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

spirit-handlebars

v1.0.1

Published

A handlebar template parser middleware for the static file generator.

Downloads

7

Readme

Spirit Handlebars

Summary

A handlebar template parser middleware for the Spirit Core static file generator.

Usage

Install through npm

( or simply download the file )

npm install spirit-handlebars

To use simply require it and pass it to the Spirit Core use function.

var spiritCore       = require( 'spirit-core' ) ;
var spiritHandlebars = require( 'spirit-handlebars' ) ;

var spirit = new SpiritCore( ) ;

spirit.use( spiritHandlebars ) ;

Configuration

The middleware will look for optional configuration settings in the Spirit Cores handlebars config property.

config.handlebars.partials String :

The relative path to the handlebar partials files.

Default value is /partials.

config.handlebars.templates String :

The relative path to the handlebar template files.

Default value is /templates.

Parsing

The middleware will use the file data's front matter as priority. As such it is recommended you use the Spirit Front Matter in addition with the handlebars middleware, but is not required.

The middleware will parse any file name or templates front matter data property that a .hb or .handlebars extension and is not in the configured partials or handlebars directory. Using the corresponding template to render the file.

The template data is derived by merging the spirit site data Object with the file data Object with the file data taking priority.

All the partials will be available globally.

For more information on parsing please visit handlebars module. For more information on file data please see Spirit Files . For more information on the spirit site data please see Spirit Site Data .

Example

In Directory structure

> = Directory
- = File

> "example"
  > "src"
    - "about.hb"
    > "templates"
      - "post.handlebars"
    > "partials"
      - "header.hb"
      - "footer.hb"
  > "dest"

In header.hb

  <html>
    <head>
      <title>{{title}}</title>
    </head>
    <body>

In footer.hb

    </body>
  </html>

In post.handlebars file

  {{> header}}
  {{{content}}}
  {{> footer}}

In about.hb

  ---
  title : 'About'
  template: 'post.handlebars'
  ---

    <h1>This is the About page</h1>
    <p>{{descirption}}</p>

Now simply use the middleware

  var SpiritCore        = require('spirit-core') ;
  var spiritFrontMatter = require('spirit-front-matter') ;
  var spiritHandlebars  = require('spirit-handlebars') ;

  var config = {
    src : "src",
    dest: "dest",
    handlebars : {
      templates : "templates",
      partials  : "partials"
    },
    site : {
      data : {
        description : "blah blah blah"
      }
    }
  } ;

  var spirit = new SpiritCore( "./example", config ) ;
  spirit.use( spiritFrontMatter ) ;
  spirit.use( spiritHandlebars ) ;
  spirit.run( ) ;

The output directory structure.

> = Directory
- = File

> "example"
  > "src"
    - "about.hb"
    > "templates"
      - "post.handlebars"
    > "partials"
      - "header.hb"
      - "footer.hb"
  > "dest"
    - "about.html"

about.html

<html>
  <head>
    <title>About</title>
  <head>
  <body>

    <h1>This is the About page</h1>
    <p>blah blah blah</p>
  </body>
</html>

For more information please visit Spirit Core .

Handmade in San Francisco California by Alex Ray .