glacier-web-cli 0.5.0

Command-line tool for creating and running Glacier applications.
{% props action: String, step: i64, steps: i64, field: Field, title: String, description: String = "", options: Vec<(String, String)> = Vec::new(), multiple: bool = false, back: String = "", optional: bool = false, inner_block: Slot = Slot::default() %}
{#- One step: action posts the answer; options: (value, text), keyed A, B, C…; multiple takes several (checkboxes, the field's value comma-separated); back: the previous step's href; optional adds Skip; inner_block: a free-text control. #}
{%- let percent = if steps > 0 { step * 100 / steps } else { 0 } %}
{%- let description = if description.is_empty() && multiple { "Choose all that apply.".to_owned() } else { description } %}
<form class="ui-questionnaire" method="post" action="{{ action }}" data-ui="questionnaire">{{ csrf_field() }}
  <div class="ui-q-progress"><div class="ui-q-progress-text"><span>Question {{ step }} of {{ steps }}</span><span>{{ percent }}%</span></div><progress class="ui-progress" value="{{ percent }}" max="100" aria-label="Progress, question {{ step }} of {{ steps }}"></progress></div>
  <fieldset class="ui-q-item"{% if field.has_errors() %} aria-describedby="{{ field.id }}-error"{% end %}>
    <legend class="ui-q-title">{{ title }}</legend>
    {%- if !description.is_empty() %}
    <p class="ui-q-desc">{{ description }}</p>
    {%- end %}
    {%- if field.has_errors() %}
    <p class="ui-field-error" id="{{ field.id }}-error">{%- for message in field.errors.iter() %}{{ message }}. {% end %}</p>
    {%- end %}
    {%- for (i, (value, text)) in options.iter().enumerate() %}
    {%- let checked = if multiple { field.value.split(',').any(|v| v.trim() == value) } else { field.value == *value } %}
    <label class="ui-q-choice"><input type="{% if multiple %}checkbox{% else %}radio{% end %}" name="{{ field.name }}" value="{{ value }}"{% if checked %} checked{% end %}><span class="ui-q-key">{{ (b'A' + i as u8) as char }}</span>{{ text }}<span class="ui-q-check"><svg class="ui-icon" viewBox="0 0 24 24" aria-hidden="true"><path d="M20 6 9 17l-5-5"/></svg></span></label>
    {%- end %}
    {{ inner_block }}
  </fieldset>
  <div class="ui-q-actions">
    {%- if !back.is_empty() %}
    <a class="ui-btn" data-variant="ghost" href="{{ back }}"><svg class="ui-icon" viewBox="0 0 24 24" aria-hidden="true"><path d="m15 18-6-6 6-6"/></svg>Back</a>
    {%- end %}
    {%- if optional %}
    <button class="ui-btn" data-variant="ghost" name="skip" value="true" formnovalidate>Skip</button>
    {%- end %}
    {%- if step >= steps %}
    <button class="ui-btn ui-q-next">Submit</button>
    {%- else %}
    <button class="ui-btn ui-q-next">Next<svg class="ui-icon" viewBox="0 0 24 24" aria-hidden="true"><path d="m9 18 6-6-6-6"/></svg></button>
    {%- end %}
  </div>
</form>