{% if arg.header %}
	<strong>{{ arg.header }}</strong><span></span><span></span>
{% endif %}

{# Note: Argument.choices may run code to determine resp. values; running these only once via 'with' variables does speed things up. #}
{% with id=token|add:"-"|add:arg.identity choices=arg.choices strdefault=arg.strdefault %}
	<label for="{{ id }}" title="{{ arg.doc }}"><em>{{ arg.identity }}</em></label>
	<span>
		{% if arg.HTML_TYPE == "text" or arg.HTML_TYPE == "url" or arg.HTML_TYPE == "number" %}
			<input id="{{ id }}"
						 name="{{ arg.identity }}"
						 type="{{ arg.HTML_TYPE }}"
						 title="{{ arg.HTML_HELP }}"
						 {% if choices %}list="{{ id }}-choices"{% endif %}
						 {{ arg.required|yesno:"required," }}
						 value="{{ arg.strgiven }}"
						 placeholder="{% if strdefault %}{{ strdefault }}{% else %}{{ arg.doc }}{% endif %}"
			>
			{% if choices %}
				<datalist id="{{ id }}-choices">
					{% for choice in choices %}
						<option value="{{ choice }}"></option>
					{% endfor %}
				</datalist>
			{% endif %}

			<img class="mbd-icon mbd-icon-small" src="{% static 'icons/clear.svg' %}" alt="Clear" title="Clear" onclick="$('#{{ id }}').prop('value', null);">
			{% if arg.strgiven %}
				<img class="mbd-icon mbd-icon-small" src="{% static 'icons/restore.svg' %}" alt="Restore" title="Restore initial value" onclick="$('#{{ id }}').prop('value', '{{ arg.strgiven }}');">
			{% endif %}
			{% if strdefault %}
				<img class="mbd-icon mbd-icon-small" src="{% static 'icons/paste.svg' %}" alt="Paste default" title="Paste default value for edit" onclick="$('#{{ id }}').prop('value', '{{ strdefault }}');">
			{% endif %}

		{% elif arg.HTML_TYPE == "select" %}
			<select id="{{ id }}" name="{{ arg.identity }}" title="{{ arg.HTML_HELP }}">
				{% for choice in choices %}
					<option value="{{ choice }}"{% if arg.strvalue == choice %} selected{% endif %}>{{ choice }}</option>
				{% endfor %}
			</select>
		{% elif arg.HTML_TYPE == "checkbox" %}
			<input id="{{ id }}" name="{{ arg.identity }}" type="{{ arg.HTML_TYPE }}" title="{{ arg.HTML_HELP }}" value="{{ True }}"{{ arg.given|yesno:" checked," }}>
		{% elif arg.HTML_TYPE == "textarea" %}
			<textarea id="{{ id }}" name="{{ arg.identity }}" title="{{ arg.HTML_HELP }}" {{ arg.required|yesno:"required," }}>{{ arg.strgiven }}</textarea>
		{% else %}
			{{ arg.identity }}: Internal error: Unknown argument type {{ arg.HTML_TYPE }}.
		{% endif %}

	</span>
	<pre>{% if verbose %}{{ arg.doc }}{% endif %}</pre>
{% endwith %}
