Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Helpers do not load (sometimes) #271

Open
DjovDev opened this issue Dec 30, 2019 · 4 comments
Open

Helpers do not load (sometimes) #271

DjovDev opened this issue Dec 30, 2019 · 4 comments

Comments

@DjovDev
Copy link

DjovDev commented Dec 30, 2019

I have a really frustrating issue, I can't seem to reproduce.

But sometimes my helpers don't seem to load. I get all kinds of errors on pages including these global helpers e.g. "Helper isequal not defined" and the whole page goes into failrue.

I define my engine as such:

var app = express();
app.set("view engine", "handlebars");

var helpers = require("./views/helpers/handlebars");

var hbs = exphbs.create({ 
    defaultLayout: "main", 
    helpers: helpers
});
app.engine("handlebars", hbs.engine);

My helper code goes as follows:

var moment = require('moment')

//helps pick value in select
exports.select = function(selected, options) {
    return options.fn(this).replace(
        new RegExp(' value=\"' + selected + '\"'),'$& selected="selected"');
}
//check if values are the same
exports.isequal = function (arg1, arg2, options) {
    return (arg1 == arg2) ? options.fn(this) : options.inverse(this);
}

//formats date object as DD/MM/YYYY
exports.ddmmyyyy = function (date,options) {
    if (moment(date)) {
        return moment(date).format('DD/MM/YYYY')
    } else {
        return "Invalid date"
    }
}

//formats date object as DD/MM/YYYY hh:mm:ss
exports.timestamp = function(date,options) {
    if (moment(date)) {
        return moment(date).format('DD/MM/YYYY HH:mm:ss')
    } else {
        return "Invalid date"
    }
} 

I am not sure if this is a bug, or something that I'm doing wrong.

@DjovDev
Copy link
Author

DjovDev commented Jan 8, 2020

Nothing? Is this project dead? :/

@UziTech
Copy link

UziTech commented Jan 8, 2020

pretty much. It looks like this was developed by Yahoo employees that have since moved on. @sahat was the last one I know that was active but according to his contribution graph he seems to have dropped off of GitHub.

@DjovDev
Copy link
Author

DjovDev commented Jan 10, 2020

That's a bummer. I have many projects running on this.

If I can believe the NPM statistics, 100.000 other (weekly) projects do as well. Oh well, might have to jump on the hype train and learn react then...

@nknapp
Copy link

nknapp commented Jan 18, 2020

I think https://github.com/barc/express-hbs does almost the same, in the same way. Might be easy to migrate. I don't know it if it more active though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants