question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Support .hbs file extension

See original GitHub issue

Been working on a side-project using keystone and I had swapped this library into the framework instead of Jade. I had taken a week off from the code and came back to my project and in porting a handlebars theme from Ghost the file syntax was .hbs and as a result my partials weren’t being loaded. I dug way into express3-handlebars, like ._loadDir to see what was going on with my partials. Only to realize eventually that it was my file-extension.

To ease developer onboarding and alleviate frustration might be best to just support the .hbs extension. I know this is minor, but I’m sure I’m not the first developer to spend several hours digging into code only to realize the minor issue.

Issue Analytics

  • State:closed
  • Created 9 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
mgan59commented, Jun 6, 2014

@daslicht I’m using the latest express3-handlebars with .hbs extension and they work. You need to remember that when you set your engine you must set the correct configurations.

Taking the example from the readme

var express = require('express'),
    exphbs  = require('express3-handlebars'),

    app = express(),
    hbs;

hbs = exphbs.create({
    // Specify helpers which are only registered on this instance.
    helpers: {
        foo: function () { return 'FOO!'; },
        bar: function () { return 'BAR!'; }
    }
});

app.engine('handlebars', hbs.engine);
app.set('view engine', 'handlebars');

you need to make it look like the following for the .hbs syntax to work. First add extname when you create the expresshbs engine. Secondly, when you mount it into express you need to change the engine key from handlebars to hbs. They must match or it will not work correctly. You can see a working example of this from my keystonejs hbs demo

var express = require('express'),
    exphbs  = require('express3-handlebars'),

    app = express(),
    hbs;

hbs = exphbs.create({
    // Specify helpers which are only registered on this instance.
    helpers: {
        foo: function () { return 'FOO!'; },
        bar: function () { return 'BAR!'; }
    },
   extname:'.hbs'
});

app.engine('hbs', hbs.engine);
app.set('view engine', 'handlebars');

hope this helps 😃

0reactions
daslichtcommented, Jun 6, 2014

app.set(‘view engine’, ‘handlebars’); is not working but when i use :

app.set(‘view engine’, ‘hbs’); !

Thank you !

Read more comments on GitHub >

github_iconTop Results From Across the Web

What is it? How to open an HBS file? - FILExt
A HBS file is a template which Handlebars template engine uses to generate a HTML ... The HBS file type is primarily associated...
Read more >
How To Open File With HBS Extension?
The following is a list of guidelines that will help you identify and solve file-related problems. Step 1. Install Visual Studio Code software....
Read more >
HBS File Extension: What Is It & How To Open It? - Solvusoft
Most HBS files can be viewed with two known software applications, typically Handlebars developed by GitHub, Inc.. and associated with the ...
Read more >
Open hbs file - File-Extensions.org
An hbs file extension is related with the Handlebars.js JavaScript library. ... HBS file extension - JavaScript Handlebars.js template ... Help how to...
Read more >
How to open .HBS file? .HBS extension Information.
.HBS file is associated with Handlebars Template developed by N/A, has a Text Format and belongs to Developer Files category. How to open...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found