Skip to content

Retain compilation runtime when registering precompiled partials #2095

@Schommer79

Description

@Schommer79

I am trying to write template modules, where a javascript module exports a template function. Ideally, each template module would be isolated so as to neither affect, nor be affected by the other handlebars runtimes (handlebars.noConflict().create()). Different templates could depend on different versions of a helper with the same name without stepping on each other. Each template module should also handle registering any helpers/partials it needs.

For simple templates, this can be done with no modification to how handlebars currently works. However, if a template requires a partial, and that partial requires other resources such as a helper, it stops working. I compile the partial template in its own runtime, with needed helpers already registered to that runtime. But when that partial template is registered in a second runtime, templates created in that runtime fail when they try to use the partial due to missing helpers.

I suspect that the runtime of the template being executed overwrites the runtime of the compiled partial and that is why it fails with helper not found.

Is it possible that partials could be tweaked to retain their compilation runtime? Or that an option could be added to allow that to happen?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions