拥有一个 npm 模块的多个实例
Having multiple instances of a npm module
我目前正在将车把实现为视图引擎。为了使用不同的 helpers/partials 为不同的用户提供服务,我需要多个 Handlebars 实例。谁能给我一个如何做到这一点的例子,因为我不知道如何实现这一点。提前致谢:)
Creates an isolated Handlebars environment.
var OtherHandlebars = Handlebars.create();
Each environment has it's own helpers and
partials. This is only necessary for use cases that demand distinct
helpers or partials. Most use cases can use the root Handlebars
environment directly.
Templates created for a given environment are
bound to that environment. This means that templates that need to run
in multiple environments will need to be recompiled or reconstructed
via Handlebars.template for each environment. This applies to partials
as well.
我目前正在将车把实现为视图引擎。为了使用不同的 helpers/partials 为不同的用户提供服务,我需要多个 Handlebars 实例。谁能给我一个如何做到这一点的例子,因为我不知道如何实现这一点。提前致谢:)
Creates an isolated Handlebars environment.
var OtherHandlebars = Handlebars.create();
Each environment has it's own helpers and partials. This is only necessary for use cases that demand distinct helpers or partials. Most use cases can use the root Handlebars environment directly.
Templates created for a given environment are bound to that environment. This means that templates that need to run in multiple environments will need to be recompiled or reconstructed via Handlebars.template for each environment. This applies to partials as well.