Giter Club home page Giter Club logo

Comments (12)

defunctzombie avatar defunctzombie commented on August 12, 2024

Are you registering the helper before rendering the view? Can you provide a simple example showing the bug.

from hbs.

olalonde avatar olalonde commented on August 12, 2024

Yes my code flow is a bit like this:

var hbs = require('hbs');

// ...

hbs.registerHelper('fromnow', function(val) {
  return 'test';
});

// ....
app.set('views', __dirname + '/views');
app.set('view engine', 'hbs');


// ... then in some route

res.render('view', {user: {name:'aa'}});

My views work fine with the builtin helpers but my own registered helpers always throw that error :(

from hbs.

defunctzombie avatar defunctzombie commented on August 12, 2024

Can you tell me what version of hbs you have installed and what version of handlebars?

from hbs.

olalonde avatar olalonde commented on August 12, 2024
├─┬ [email protected]
│ └─┬ [email protected]

from hbs.

olalonde avatar olalonde commented on August 12, 2024

also

from hbs.

olalonde avatar olalonde commented on August 12, 2024

been stuck on this for almost 2 hours, do you have any idea of what might be the problem?

from hbs.

defunctzombie avatar defunctzombie commented on August 12, 2024

No, I do not. I would recommend removing anything else in the app and creating a minimal broken example with nothing extra.

from hbs.

olalonde avatar olalonde commented on August 12, 2024

Damn it, the bug was cause by this little piece of code:

if(app.get('env') != 'production') {
  // todo: make last_req available
  console.log('');
  console.log('You can now type Javascript expressions in the interactive REPL.');
  console.log('Some useful expressions:');
  console.log('app.routes');
  console.log('app.models');
  console.log('app.lastReq');
  console.log('');
  repl.start('>>> '.green);
}

I still can't figure what might be the problem here :( At least I found the bug

from hbs.

cfjedimaster avatar cfjedimaster commented on August 12, 2024

Just an FYI, I'm running into this now too.

from hbs.

cfjedimaster avatar cfjedimaster commented on August 12, 2024

Some details on my bug. Here is my app.js. You can see I'm regstering the helper (using a simple string for now in the result).

https://gist.github.com/cfjedimaster/5746567

And here is my view:

https://gist.github.com/cfjedimaster/5746569

from hbs.

cfjedimaster avatar cfjedimaster commented on August 12, 2024

Sorry - it must have been a typo. It is working ok now.

from hbs.

cfjedimaster avatar cfjedimaster commented on August 12, 2024

Heh, I see it. I called dateHelper in my view, but it was dateFormat.

from hbs.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.