Skip to content

hmpl-language/hmpl-loader

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 

Repository files navigation

hmpl-loader

npm-version

This loader was created for files with the .hmpl extension, which are converted using the hmpl-js package. This loader is designed for webpack.

Loader works with hmpl-js version 1.0.4 or higher

Installation

npm i -D hmpl-loader

Usage:

In the webpack.config.js file you can specify the following lines of code:

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

After webpack.config.js has been changed, in js files (for example, in main.js), you can import a file with the .hmpl extension and receive a template function in response.

main.hmpl

<div>
  {{#request src="/api/test"}}
  {{/request}}
</div>

main.js

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

const elementObj = templateFn();

Options

The loader supports the compile function options.

module.exports = {
  module: {
    rules: [
      {
        test: /\.hmpl$/i,
        use: {
          loader: "hmpl-loader",
          options: {
            memo: true,
            autoBody: {
              formData: true,
            },
          },
        },
      },
    ],
  },
};

The list of options is described in the documentation here.

Changelog

Changelog

License

Licensed under MIT

About

Loader for files with hpml extension for Webpack

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published