Skip to content

Load precompiled templates from Typescript  #1528

@xjrcode

Description

@xjrcode

For anyone trying to load precompiled templates from typescript (for sending an email for instance):

  1. You have to precompile with the -c option: handlebars templates/*.handlebars -f templates/precompiled.js -c handlebars/runtime
  2. Load the Handlebars runtime and then the templates file:
import * as Handlebars from 'handlebars/runtime';
import './templates/precompiled'; // load templates
  1. Use as always: Handlebars.templates['name-of-file-without-extension'](data)

I hope this helps you and you don't waste many hours like me.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions