Lädt...

🔧 🎙️We have implemented new features in HMPL to help developers make web apps smaller in size🔥


Nachrichtenbereich: 🔧 Programmierung
🔗 Quelle: dev.to

Today, we have prepared some cool features that can really help developers make web applications much smaller in size. These features themselves qualitatively complement the already good template language with additional and interesting functionality.

They have been in development for several months now and are also quite expandable, making the future much more promising and clear.

⚙️ Automatic body generation for RequestInit

One of the innovations is the generation of the body of the request to the server. This functionality is very convenient when working with forms, because you do not have to manually specify FormData.

import { compile } from "hmpl-js";

const templateFn = compile(
  `<div>
  <table>
    <caption>
      List of products in the store
    </caption>
    <thead>
      <tr>
        <th scope="col">Product name</th>
        <th scope="col">Quantity</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td>Coca Cola</td>
        <td>10</td>
      </tr>
      <tr>
        <td>Lays</td>
        <td>4</td>
      </tr>
      {
        {
          "src":"/api/products",
          "after":"submit:#form",
          "autoBody":true,
          "indicators": [
            {
              "trigger": "pending",
              "content": "<tr><td>Loading...</td><td>Loading...</td></tr>"
            }
          ]
        }
      }
    </tbody>
  </table>
  <form id="form">
    <div class="form-example">
      <label>Product name: </label>
      <input type="text" name="product" id="product" required /><br/>
      <label>Quantity: </label>
      <input type="number" name="quantity" id="quantity" required />
    </div>
    <div class="form-example">
      <input type="submit" value="Add product" />
    </div>
  </form>
</div>
  `
);
const obj = templateFn({ credentials: "same-origin" });
const wrapper = document.getElementById("wrapper");
wrapper.appendChild(obj.response);

Here, we send a request to add a product to the table. If it weren't for this functionality, we would have to manually set the parameters via new FormData().set(), but this is done automatically.

// Detect dark theme var iframe = document.getElementById('tweet-1896132750966706564-355'); if (document.body.className.includes('dark-theme')) { iframe.src = "https://platform.twitter.com/embed/Tweet.html?id=1896132750966706564&theme=dark" }

Also, it would be great if you supported the project with your star! Thanks ❤️!

💎 Star HMPL ★

🔄 Indicators

Indicators are HTML components that are displayed depending on the status of a server request.

{
  {
    "src": "http://localhost:5000/api/test",
    "indicators": [
       {
         "trigger": "pending",
         "content": "<p>Loading...</p>"
       },
       {
         "trigger": "rejected",
         "content": "<p>Error</p><button>reload</button>"
       }
    ]
  }
}

With their help, you can create custom loaders that will indicate to the user that the server has not yet returned a response.

loading

🔧 Fully tested

The test coverage of the entire application is 100%, so this functionality will work with a minimum number of bugs.

Fully tested

You can view the report with tests on Codecov, and the tests themselves are in the test folder.

👀 Ready to make your web app smaller?

  • Node Package Manager: You can download it via npm using the command npm i hmpl-js

  • Content Delivery Network: You can include a file with a dependency via CDN using the following code:

<script src="https://unpkg.com/json5/dist/index.js"></script>
<script src="https://unpkg.com/hmpl-js/dist/hmpl.min.js"></script>
  • Locally: Or, there is a similar option with the second one, just download the file to your local machine.

  • Starter project: There is also a starter project that can be deployed via the command npx degit hmpl-language/hello-hmpl-starter my-project

💬 Feedback

You can write your thoughts about the new features in the comments, it will be interesting to read! Or, there is a thematic discord channel for questions and suggestions, there I or someone else will try to answer!

✅ This project is Open Source

So you can take part in it too! This also means you can use it for commercial purposes:

Repo: https://github.com/hmpl-language/hmpl
Website: https://hmpl-lang.dev

Thank you for reading!

Thanks!

...

🔧 🎙️We have implemented new features in HMPL to help developers make web apps smaller in size🔥


📈 127.97 Punkte
🔧 Programmierung

🔧 🎙️We've implemented new features in HMPL to help developers make web apps more secure🔥


📈 99.35 Punkte
🔧 Programmierung

🔧 🎙️We have implemented new features in HMPL to make developers' web apps more secure🔥


📈 98.68 Punkte
🔧 Programmierung

🔧 🎙️We build HMPL to help developers make web apps smaller in size🔥


📈 97.64 Punkte
🔧 Programmierung

🔧 We build HMPL to help developers make web apps smaller in size🔥


📈 71.12 Punkte
🔧 Programmierung

🔧 🔥We build HMPL to help developers make web apps smaller 🗄️ in size


📈 71.12 Punkte
🔧 Programmierung

🔧 How to reduce javascript file size on client using HMPL?


📈 33.43 Punkte
🔧 Programmierung

🔧 🎙️We have updated the site and here is what I want to say...


📈 31.7 Punkte
🔧 Programmierung

🔧 🎙️We have updated the site and here is what I want to say...


📈 31.7 Punkte
🔧 Programmierung

🔧 🎙️We have updated the site and here is what I want to say🔥


📈 31.7 Punkte
🔧 Programmierung

🔧 🎙️We have updated the site and here is what I want to say...


📈 31.7 Punkte
🔧 Programmierung

🔧 🎙️We have updated the site and here is what I want to say...


📈 31.7 Punkte
🔧 Programmierung

🍏 3 Ways to Make iPhone Pictures a Smaller File Size


📈 29.17 Punkte
🍏 iOS / Mac OS

📰 Microsoft Plans to Make Monthly Windows 10 Updates Smaller in Size


📈 29.17 Punkte
📰 IT Security Nachrichten

📰 Microsoft Plans to Make Monthly Windows 10 Updates More Smaller in Size


📈 29.17 Punkte
📰 IT Security Nachrichten

📰 The smaller the business, the smaller the focus on cybersecurity


📈 26.67 Punkte
📰 IT Security Nachrichten

🔧 🎙️We are launching the project on DevHunt!🔥


📈 26.53 Punkte
🔧 Programmierung

🔧 HMPL - new template language for fetching HTML from API


📈 25.65 Punkte
🔧 Programmierung

🔧 📢 HMPL v3.0: New big update!


📈 25.65 Punkte
🔧 Programmierung

🍏 iPhone 17 Plus Screen Size Might Be Smaller Than Current Plus Variant, Says Report


📈 23.44 Punkte
🍏 iOS / Mac OS

🪟 Razer's Seiren Mini delivers pro sound in a smaller size for just $50


📈 23.44 Punkte
🪟 Windows Tipps

🐧 What happen when you write a file smaller than the chunk size in a RAID ?


📈 23.44 Punkte
🐧 Linux Tipps

🔧 🌷Creating a Gallery App in JavaScript with HMPL


📈 23.33 Punkte
🔧 Programmierung

🔧 🔥Introducing the HMPL VS Code Extension


📈 23.33 Punkte
🔧 Programmierung