@vojtaholik/static-kit-core 2.1.12 → 2.1.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/template-compiler.ts +4 -3
package/package.json
CHANGED
package/src/template-compiler.ts
CHANGED
|
@@ -255,9 +255,10 @@ function compileElement(element: Element, indent: number): string {
|
|
|
255
255
|
continue;
|
|
256
256
|
}
|
|
257
257
|
// Conditionally render attribute only if value is truthy
|
|
258
|
-
|
|
259
|
-
code += `${pad}
|
|
260
|
-
code += `${pad}
|
|
258
|
+
const varName = attrName.replace(/[^a-zA-Z0-9_]/g, "_");
|
|
259
|
+
code += `${pad}const _${varName}Val = ${attr.value};\n`;
|
|
260
|
+
code += `${pad}if (_${varName}Val) {\n`;
|
|
261
|
+
code += `${pad} out += " ${attrName}=\\"" + escapeAttr(_${varName}Val) + "\\"";\n`;
|
|
261
262
|
code += `${pad}}\n`;
|
|
262
263
|
}
|
|
263
264
|
}
|