简体   繁体   中英

Handlebars does not find dynamic partial

I have this partial:

_info.hbs

info

And I have this helper function in my helpers file:

helper.js

module.exports = {
  infoPartial: function(context, options) {
    return '/absolute/path/to/_info.hbs';    
  }
};

My template is this:

{{> ('infoPartial') }}

And when I call my template I get

"The partial /absolute/path/to/_info could not be found"

I don't know, why handlebars can't find the partial. Maybe someone can help me with this problem.

My understanding is that you cannot pass an absolute path to a partial to the partial resolver. The path resolution is done by the framework. Instead of the path, you should just be passing the name of the partial. In your case, this would mean replacing '/absolute/path/to/_info.hbs' with simply '_info' .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM