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

Discover more from Coursity

Subscribe to get the latest posts sent to your email.

Leave a Comment

Your email address will not be published. Required fields are marked *

Discover more from Coursity

Subscribe now to keep reading and get access to the full archive.

Continue reading

Scroll to Top
* add your javascript code here.