1.0.0 • Published 3 years ago

parcel-plugin-handlebars-precompile-ts v1.0.0

Weekly downloads
-
License
ISC
Repository
github
Last release
3 years ago

parcel-plugin-handlebars-precompile

Precompile handlebars templates into typescript allowing them to be imported as a regular typescript source. It is up to you how and when the template will be rendered.

Install

npm install --save-dev parcel-plugin-handlebars-precompile-ts

Usage

Import your handlebars template:

// index.ts
import templateFunction from "./template.hbs";
document.body.innerHTML = templateFunction();

Import index.ts from your index.html file:

<!DOCTYPE html>
<html>
  <!-- index.html -->
  ...
  <body>
    <script src="./index.ts"></script>
  </body>
  ...
</html>

Run the parcel bundler:

parcel build index.html

Credits