Express.js hbs module - register partials from .hbs file

后端 未结 6 1974
陌清茗
陌清茗 2020-12-04 16:05

I\'m using the handlebars.js hbs wrapper in express.js. I have templates working fine, but I\'m needing to add in partials to be rendered with my views.

I\'d like to

6条回答
  •  心在旅途
    2020-12-04 16:21

    For me I had template file my-partial.hbs

    Then I tried to access them via:

    {{> my-partial }}
    

    But the partial was stored in hbs as my_partial regardless of the filename.

    This is thanks to hbs version 3.1.0 line 218

    .slice(0, -(ext.length)).replace(/[ -]/g, '_').replace('\\', '/');
    

    This is in the readme

提交回复
热议问题