Use the precompile goal of the handlebars-maven-plugin to convert Handlebars or Mustache templates into JavaScript files using the handlebars.js runtime. This is useful for client-side rendering where templates need to be pre-processed.
You can run this via the Maven lifecycle (typically during prepare-package) or manually using the command line.
<plugin>
<groupId>com.github.jknack</groupId>
<artifactId>handlebars-maven-plugin</artifactId>
<version>${handlebars-version}</version>
<executions>
<execution>
<id>precompile</id>
<phase>prepare-package</phase>
<goals>
<goal>precompile</goal>
</goals>
<configuration>
<output>${project.build.directory}/${project.build.finalName}/js/helpers.js</output>
<prefix>${basedir}/src/main/webapp</prefix>
<suffix>.hbs</suffix>
<handlebarsJsFile>/handlebars-v1.3.0.js</handlebarsJsFile>
<minimize>false</minimize>
<runtime></runtime>
<amd>false</amd>
<encoding>UTF-8</encoding>
<templates>
<template>mytemplateA</template>
<template>mytemplateB</template>
</templates>
</configuration>
</execution>
</executions>
</plugin>
Or via CLI:
mvn handlebars:precompile