DEV Community

antonmak1
antonmak1

Posted on • Edited on

How to work with .hmpl file extension in javascript?

In order to work with files with the .hmpl extension, you can install a webpack and loader for it hmpl-loader. Since version 0.0.2, the loader connection looks like this:

webpack.config.js

module.exports = {
  module: {
    rules: [
      {
        test: /\.hmpl$/i,
        use: ["hmpl-loader"],
      }
    ]
  }
}
Enter fullscreen mode Exit fullscreen mode

main.hmpl

<div><request src="/api/test"></request></div>
Enter fullscreen mode Exit fullscreen mode

main.js

const templateFn = require("./main.hmpl");

const elementObj = templateFn();
Enter fullscreen mode Exit fullscreen mode

Top comments (0)