A minimal starter template to get started with HMPL.
npx degit hmpl-language/hello-hmpl-starter hello-hmpl
cd hello-hmpl
npm install
hello-hmpl/
|--mock/
|--public/
|--src/
| |--hmpl/
| |--main.js
|--index.html
|--package.json
|--vite.config.js
|--vite-plugin-hmpl.js
|--README.md
Create a new HMPL template in src/hmpl/HelloWorld.hmpl
:
<div>
<div>
{{
src: "/api/hello",
indicators: [
{ trigger: "pending", content: "<p>Loading...</p>" },
{ trigger: "rejected", content: "<p>Error!!</p>" }
]
}}
</div>
</div>
Then, load it into src/main.js
:
import helloWorld from "./hmpl/HelloWorld.hmpl";
const { response } = helloWorld();
document.body.appendChild(response);
Now, your UI will dynamically render data from the server!
This project was created by Saptarshi Mula. Many thanks to him!