Skip to content

Commit ffa7c09

Browse files
committed
version 3.2.1
1 parent cdcebe0 commit ffa7c09

File tree

11 files changed

+57
-48
lines changed

11 files changed

+57
-48
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# Changelog
22

3+
## 3.2.1 (2025-11-29)
4+
5+
- Create the `HMPLTemplateFunctionOptions` type
6+
- Speeding up code execution
7+
38
## 3.2.0 (2025-11-12)
49

510
- Adding the `bind` property

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ This method involves downloading through npm or other package managers.
166166
npm i hmpl-js
167167
```
168168

169-
Along the path `node-modules/hmpl/dist` you can find two files that contain a regular js file and a minified one.
169+
Along the path `node_modules/hmpl/dist` you can find two files that contain a regular js file and a minified one.
170170

171171
### CDN
172172

dist/hmpl.js

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1874,19 +1874,13 @@
18741874
}
18751875
const buildValue = () => {
18761876
const resultParts = [...constructorVal];
1877-
for (const [key, indexes] of Object.entries(
1878-
dynamicValues
1879-
)) {
1880-
let replaceVal;
1877+
for (const key in dynamicValues) {
1878+
const indexes = dynamicValues[key];
18811879
const { value, prefix } = statusValues[key];
1882-
if (value !== undefined) {
1883-
replaceVal = `${prefix}${key}-${value}`;
1884-
} else {
1885-
replaceVal = "";
1886-
}
1887-
1888-
for (const idx of indexes) {
1889-
resultParts[idx] = replaceVal;
1880+
const replaceVal =
1881+
value !== undefined ? `${prefix}${key}-${value}` : "";
1882+
for (let i = 0; i < indexes.length; i++) {
1883+
resultParts[indexes[i]] = replaceVal;
18901884
}
18911885
}
18921886
return resultParts.join("");

dist/hmpl.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/hmpl.runtime.js

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1548,16 +1548,12 @@ var compile = (template, options = {}) => {
15481548
}
15491549
const buildValue = () => {
15501550
const resultParts = [...constructorVal];
1551-
for (const [key, indexes] of Object.entries(dynamicValues)) {
1552-
let replaceVal;
1551+
for (const key in dynamicValues) {
1552+
const indexes = dynamicValues[key];
15531553
const { value: value2, prefix } = statusValues[key];
1554-
if (value2 !== void 0) {
1555-
replaceVal = `${prefix}${key}-${value2}`;
1556-
} else {
1557-
replaceVal = "";
1558-
}
1559-
for (const idx of indexes) {
1560-
resultParts[idx] = replaceVal;
1554+
const replaceVal = value2 !== void 0 ? `${prefix}${key}-${value2}` : "";
1555+
for (let i = 0; i < indexes.length; i++) {
1556+
resultParts[indexes[i]] = replaceVal;
15611557
}
15621558
}
15631559
return resultParts.join("");

dist/index.d.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ import {
2424
HMPLDisallowedTags,
2525
HMPLSanitize,
2626
HMPLClearInterval,
27-
HMPLBindOptions
27+
HMPLBindOptions,
28+
HMPLTemplateFunctionOptions
2829
} from "../build/types";
2930

3031
const hmpl = {
@@ -60,5 +61,6 @@ export type {
6061
HMPLDisallowedTags,
6162
HMPLSanitize,
6263
HMPLClearInterval,
63-
HMPLBindOptions
64+
HMPLBindOptions,
65+
HMPLTemplateFunctionOptions
6466
};

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "hmpl-js",
3-
"version": "3.2.0",
3+
"version": "3.2.1",
44
"description": "🐜 HMPL.js is a lightweight server-oriented template language for JavaScript. Fetch HTML, render it safely, and keep apps dynamic, modern, and small.",
55
"main": "dist/index.js",
66
"types": "dist/index.d.ts",

src/main.ts

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@ import {
3535
HMPLDynamicValues,
3636
HMPLStatusValue,
3737
HMPLBindOptions,
38-
HMPLStatusValuesGenerator
38+
HMPLStatusValuesGenerator,
39+
HMPLTemplateFunctionOptions
3940
} from "./types";
4041

4142
/**
@@ -1986,10 +1987,7 @@ export const compile: HMPLCompile = (
19861987
requestFunction: HMPLRequestFunction
19871988
) => {
19881989
const templateFunction: HMPLTemplateFunction = (
1989-
options:
1990-
| HMPLIdentificationRequestInit[]
1991-
| HMPLRequestInit
1992-
| HMPLRequestInitFunction = {}
1990+
options: HMPLTemplateFunctionOptions = {}
19931991
): HMPLInstance => {
19941992
const statusValues: HMPLStatusValues = {};
19951993
for (const key in statusValuesGenerator) {
@@ -2042,17 +2040,15 @@ export const compile: HMPLCompile = (
20422040
}
20432041
const buildValue = () => {
20442042
const resultParts = [...constructorVal];
2045-
for (const [key, indexes] of Object.entries(dynamicValues)) {
2046-
let replaceVal: string;
2043+
for (const key in dynamicValues) {
2044+
const indexes = dynamicValues[key];
2045+
20472046
const { value, prefix } = statusValues[key];
2048-
if (value !== undefined) {
2049-
replaceVal = `${prefix}${key}-${value}`;
2050-
} else {
2051-
replaceVal = "";
2052-
}
2047+
const replaceVal =
2048+
value !== undefined ? `${prefix}${key}-${value}` : "";
20532049

2054-
for (const idx of indexes) {
2055-
resultParts[idx] = replaceVal;
2050+
for (let i = 0; i < indexes.length; i++) {
2051+
resultParts[indexes[i]] = replaceVal;
20562052
}
20572053
}
20582054
return resultParts.join("");

src/types.ts

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -380,14 +380,19 @@ type HMPLCompile = (
380380
options?: HMPLCompileOptions // Options that control how compilation occurs (e.g., memoization).
381381
) => HMPLTemplateFunction;
382382

383+
/**
384+
* Sets options for the template function.
385+
*/
386+
type HMPLTemplateFunctionOptions =
387+
| HMPLIdentificationRequestInit[]
388+
| HMPLRequestInit
389+
| HMPLRequestInitFunction;
390+
383391
/**
384392
* The function returned in response to the compile function. Creates template instances.
385393
*/
386394
type HMPLTemplateFunction = (
387-
options?:
388-
| HMPLIdentificationRequestInit[]
389-
| HMPLRequestInit
390-
| HMPLRequestInitFunction
395+
options?: HMPLTemplateFunctionOptions
391396
) => HMPLInstance;
392397

393398
type HMPLDynamicValues = Record<string, number[]>;
@@ -418,6 +423,7 @@ export {
418423
HMPLRenderFunction,
419424
HMPLCompile,
420425
HMPLTemplateFunction,
426+
HMPLTemplateFunctionOptions,
421427
HMPLAutoBodyOptions,
422428
HMPLDisallowedTag,
423429
HMPLDisallowedTags,

www/app/src/content/docs/changelog.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,11 @@ title: Changelog
33
description: Version history and updates for HMPL
44
---
55

6+
## 3.2.1 (2025-11-29)
7+
8+
- Create the `HMPLTemplateFunctionOptions` type
9+
- Speeding up code execution
10+
611
## 3.2.0 (2025-11-12)
712

813
- Adding the `bind` property

0 commit comments

Comments
 (0)