Update HtmlBuilder5.java

This commit is contained in:
string 2025-05-13 18:34:59 +05:30
parent 67b719e277
commit c919a718e9

View File

@ -27,9 +27,18 @@ public class HtmlBuilder5 {
// Start tag // Start tag
html.append("<").append(tag); html.append("<").append(tag);
String clazz = getString(node, "class", ""); // String clazz = getString(node, "class", "");
if (!clazz.isEmpty()) { // if (!clazz.isEmpty()) {
html.append(" class=\"").append(clazz).append("\""); // html.append(" class=\"").append(clazz).append("\"");
// }
//
// <div class="newsletter-2-wrapper">
// Common attributes handling
List<String> commonAttributes = java.util.Arrays.asList("class", "id", "type", "placeholder", "href", "src",
"alt", "title", "target", "name", "value");
for (String attr : commonAttributes) {
appendAttribute(html, node, attr);
} }
html.append(">"); html.append(">");
@ -39,12 +48,6 @@ public class HtmlBuilder5 {
html.append(text); html.append(text);
} }
// placehoder content
// String placeholder = getString(node, "placeholder", "");
// if (!placeholder.isEmpty()) {
// html.append(" placeholder=\"").append(clazz).append("\"");
// }
// Single icon // Single icon
Object iconObj = node.get("icon"); Object iconObj = node.get("icon");
if (iconObj instanceof String) { if (iconObj instanceof String) {
@ -117,6 +120,14 @@ public class HtmlBuilder5 {
return html.toString(); return html.toString();
} }
private static void appendAttribute(StringBuilder html, Map<String, Object> node, String attr) {
String val = getString(node, attr, "");
if (!val.isEmpty()) {
html.append(" ").append(attr).append("=\"").append(val).append("\"");
}
}
private static String getIconEmoji(String label) { private static String getIconEmoji(String label) {
label = label.toLowerCase(); label = label.toLowerCase();
if (label.contains("facebook")) if (label.contains("facebook"))