{% comment %} Generates the HTML form and the jQuery scripts for: - token [swap]s - class [toggle]s - DOM [amend]ers Expects: include.verb: String (swap|toggle|amend) include.form: String (select|buttons) include.opts: Array of Scalars or {slug:,text:} include.func: String (amenders only); name of predefined function OR .js file Optional: include.id: String (becomes form_id) include.pick: String; the slug of the default option include.slug: Token name for dictionary-free swaps include.targ: String; the ID of the target element to amend include.href: Liquid; For URL-based changers, non-variable portion of URL include.args: Object; a way to pass an object to your function template include.icon: String; FontAwesome reference include.text: String; label for form field {% endcomment %} {% assign handler = handler | default: 0 | plus: 1 %} {% assign verb = include.verb %} {% assign form = include.form | default: "select" %} {% assign pick = include.pick | default: "" %} {% capture id_def %}handler-{{handler}}-{{form}}{% endcapture %} {% assign form_id = include.id | default: id_def %} {% assign func = include.func %} {% assign href = include.href %} {% assign targ = include.targ %} {% case form %} {% when "select" %} {% assign selected = "" %}
{% if include.text %} {% endif %}
{% when "buttons" %} {% if include.text or include.icon %} {% endif %}
{% for item in include.opts %} {% if item['text'] %} {% assign text = item['text'] %} {% assign value = item['slug'] %} {% else %} {% assign text = item %} {% assign value = item %} {% endif %} {% endfor %}
{% endcase %}