Mercurial > libervia-templates
changeset 269:edefc1f25219
bulma (input/field): fixed use of `attrs` in `field`, added args, replaced use of `kwargs`
author | Goffi <goffi@goffi.org> |
---|---|
date | Fri, 14 Aug 2020 08:34:07 +0200 |
parents | ce2fd7a3911d |
children | 2378084522e1 |
files | sat_templates/templates/bulma/input/field.html |
diffstat | 1 files changed, 13 insertions(+), 13 deletions(-) [+] |
line wrap: on
line diff
--- a/sat_templates/templates/bulma/input/field.html Fri Aug 14 08:30:11 2020 +0200 +++ b/sat_templates/templates/bulma/input/field.html Fri Aug 14 08:34:07 2020 +0200 @@ -11,7 +11,7 @@ <label for="{{cur_id}}" class="label">{{label}}</label> {% endif %} <div class="control{% if icon_left %} has-icons-left{% endif %}{% if icon_right %} has-icons-right{% endif %}"> - <input id="{{cur_id}}" class="input" type="{{type}}" name="{{name}}" {{"required" if required}}{{{'value': value}|xmlattr}}{{attrs or {}|xmlattr}}> + <input id="{{cur_id}}" class="input" type="{{type}}" name="{{name}}" {{"required" if required}}{{{'value': value}|xmlattr}}{{(attrs or {})|xmlattr}}> {% if icon_left %} <span class="icon is-left"> {# we use <i> with font from CSS instead of SVG, because using directly SVG doesn't play way with Bulma's control #} @@ -30,7 +30,7 @@ </div> {% endmacro %} -{% macro select(name, options_list, selected=none, required=false, multiple=false) %} +{% macro select(name, options_list, selected=none, required=false, multiple=false, class='') %} {# selection of elements with <select> @param name: name of the field @@ -39,15 +39,15 @@ @param required(bool): true this field is required @param multiple(bool): true is multiple selection is possible #} - <select name="{{name}}" class="form_input {{kwargs.pop('class', '')}}" {{"required" if required}}> + <select name="{{name}}" class="form_input {{class}}" {{"required" if required}}> {% for value, label in options_list %} <option value="{{value}}" {{'selected' if selected and value in selected}}>{{label}}</option> {% endfor %} </select> {% endmacro %} -{% macro choices(name, choices_list, checked=none) %} - <div class="control {{kwargs.pop('class', '')}}"> +{% macro choices(name, choices_list, checked=none, class='') %} + <div class="control {{class}}"> {% for choice, label in choices_list %} <label class="radio" for="{{name|cur_gidx}}"> <input id="{{name|next_gidx}}" type="radio" name="{{name}}" value="{{choice}}"{{" checked" if checked==choice}}> {{label}} @@ -66,16 +66,16 @@ <input id="{{cur_id}}" type="checkbox" {% if checked %}checked=checked{% endif %}> {% endmacro %} -{% macro text(name, label="", value=none, class='', placeholder=none, required=false, icon_left=none, icon_right=none) %} - {{ field("text", name=name, label=label, value=value, class=class, required=required, icon_left=icon_left, icon_right=icon_right, attrs={'placeholder': placeholder}) }} +{% macro text(name, label="", value=none, class='', placeholder=none, required=false, pattern=none, title=none, autocomplete=none, icon_left=none, icon_right=none) %} + {{ field("text", name=name, label=label, value=value, class=class, required=required, icon_left=icon_left, icon_right=icon_right, attrs={'placeholder': placeholder, 'pattern': pattern, 'title': title, 'autocomplete': autocomplete}) }} {% endmacro %} -{% macro password(name, label="", required=false, icon_left=none, icon_right=none) %} - {{ field("password", name=name, label=label, required=required, icon_left=icon_left, icon_right=icon_right) }} +{% macro password(name, label="", value=none, required=false, minlength=none, icon_left=none, icon_right=none) %} + {{ field("password", name=name, label=label, value=value, required=required, icon_left=icon_left, icon_right=icon_right, attrs={'minlength': minlength}) }} {% endmacro %} -{% macro email(name, label="", required=false) %} - {{ field("email", name=name, label=label, required=required) }} +{% macro email(name, label="", required=false, value=none, icon_left=none, icon_right=none) %} + {{ field("email", name=name, label=label, value=value, required=required, icon_left=icon_left, icon_right=icon_right) }} {% endmacro %} {% macro date(name, label="", required=false) %} @@ -107,13 +107,13 @@ <input type="hidden" name="{{name}}" value="{{value}}"> {% endmacro %} -{% macro submit(text=_("Send"), id=none, class='') %} +{% macro submit(text=_("Send"), id=none, class='', attrs=none) %} {# submit button @param text(str): label of the button @param id(none, str): id of the element #} <div class="control {{class}}"> - <button{{ {'id': id}|xmlattr }} class="button is-primary form_submit {{kwargs.pop('class', '')}}" type="submit">{{text}}</button> + <button{{ {'id': id}|xmlattr }} class="button is-primary form_submit {{class}}" type="submit"{{(attrs or {})|xmlattr}}>{{text}}</button> </div> {% endmacro %}