Format html output of item_form.html template

- Remove redundant spaces
- Cleaner html in "view source"
- Better html comments
This commit is contained in:
Candifloss 2025-03-17 15:51:10 +05:30
parent f254b0ea46
commit deeaf9e645

View File

@ -18,37 +18,34 @@
{% for attrib in item_attributes -%} {% for attrib in item_attributes -%}
<p> <p>
<label for="{{ attrib.attrib_name }}">{{ attrib.display_name }}:</label> <label for="{{ attrib.attrib_name }}">{{ attrib.display_name }}:</label>
{% if attrib.html_input_type == "select" %} {%- if attrib.html_input_type == "select" %}
<!-- Render a dropdown for select attributes --> <!-- Dropdown for select fields -->
<select <select id="{{ attrib.attrib_name }}" name="{{ attrib.attrib_name }}"
id="{{ attrib.attrib_name }}" {%- if attrib.required -%} required {%- endif -%}
name="{{ attrib.attrib_name }}" >
{% if attrib.required %} required {% endif %} {% for option in attrib.options -%}
> <option value="{{ option }}"
{% for option in attrib.options -%} {%- if attrib.default_val is not none and attrib.default_val == option %} selected {%- endif -%}>{{ option -}}
<option value="{{ option }}" {% if item and item[attrib.attrib_name] == option %}selected{% endif %}>{{ option }}</option> </option>
{% endfor %} {% endfor %}
</select> </select>
{% else %} {%- else %}
<!-- Render an input field for other attributes --> <!-- Input field for other inputs -->
<input <input id="{{ attrib.attrib_name }}" name="{{ attrib.attrib_name }}" type="{{ attrib.html_input_type }}"
id="{{ attrib.attrib_name }}" {%- if attrib.required %} required {%- endif %}
type="{{ attrib.html_input_type }}" {%- if attrib.min_val %} min="{{ attrib.min_val }}" {%- endif %}
name="{{ attrib.attrib_name }}" {%- if attrib.max_val %} max="{{ attrib.max_val }}" {%- endif %}
{% if attrib.required %} required {% endif %} {%- if attrib.step %} step="{{ attrib.step }}" {%- endif %}
{% if attrib.min_val is not none %} min="{{ attrib.min_val }}" {% endif %} {%- if attrib.max_length %} maxlength="{{ attrib.max_length }}" {%- endif %}
{% if attrib.max_val is not none %} max="{{ attrib.max_val }}" {% endif %} {%- if attrib.min_length %} minlength="{{ attrib.min_length }}" {%- endif %}
{% if attrib.step is not none %} step="{{ attrib.step }}" {% endif %} {%- if attrib.regex %} pattern="{{ attrib.regex }}" {%- endif %}
{% if attrib.max_length is not none %} maxlength="{{ attrib.max_length }}" {% endif %} {%- if item %}
{% if attrib.min_length is not none %} minlength="{{ attrib.min_length }}" {% endif %} value="{{ item[attrib.attrib_name] }}"
{% if attrib.regex is not none %} pattern="{{ attrib.regex }}" {% endif %} {%- else %}
{% if item %} {%- if attrib.default_val is not none %} value="{{ attrib.default_val }}" {%- endif %}
value="{{ item[attrib.attrib_name] }}" {%- endif -%}
{% else %} />
{% if attrib.default_val is not none %} value="{{ attrib.default_val }}" {% endif %} {%- endif %}
{% endif %}
/>
{% endif %}
</p> </p>
{% endfor %} {% endfor %}
<p><input type="submit" value="{% if item %}Update{% else %}Submit{% endif %}" /></p> <p><input type="submit" value="{% if item %}Update{% else %}Submit{% endif %}" /></p>