Skip to content

andyburke-forks/metalsmith-handlebars

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 

Repository files navigation

metalsmith-handlebars

A basic implimentation of handlebars for metalsmith

I made this plugin as an alternative to metalsmith-jstransformer so that the handlebars inline templating functionality can be leveraged. This means you can use handlebars like this:

src/index.hbs
---
title: Home
---
{{#> main-layout }}
    {{#* inline "content-block" }}
        Hello, welcome to my metalsmith static site.
    {{/inline}}
{{/main-layout}}
partials/main-layout.hbs
<html>
    <head>
    </head>
    <body>
        {{>content-block}}
    </body>
</html>

The plugin can be used in the metalsmith 'use' definition like this:

const Metalsmith = require('metalsmith'),
      handlebars = require('metalsmith-handlebars');

Metalsmith(__dirname)
    .use(handlebars({
        pattern: '**/*.hbs', // defaults to '**'
        partials: 'partials', // defaults to 'partials' in the root
        targetExtension: 'html' // defaults to html
    }))
    .build(function(err) {
        if (err) throw err;
        console.log('Build finished!');
    });

About

A basic implimentation of handlebars for metalsmith

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 100.0%