# HG changeset patch # User Goffi # Date 1594883314 -7200 # Node ID 60bf3e45d7b25b0a4bb68170f62d18a466d3adbd # Parent a841837afe78a3c07cd34de1810da3ef386c364a bulma (input/field): don't use kwargs anymore: `**kwargs` syntax is not supported by `nunjucks`. To work around this, most important arguments have been added directly to macros, and an extra `attrs` argument can be used for others. diff -r a841837afe78 -r 60bf3e45d7b2 sat_templates/templates/bulma/input/field.html --- a/sat_templates/templates/bulma/input/field.html Thu Jul 16 09:08:34 2020 +0200 +++ b/sat_templates/templates/bulma/input/field.html Thu Jul 16 09:08:34 2020 +0200 @@ -1,17 +1,17 @@ {# macros to create form fields #} -{% macro field(type, name, label="", help="", required=false, icon_left=none, icon_right=none) %} +{% macro field(type, name, label="", value=none, class='', help="", required=false, icon_left=none, icon_right=none, attrs=none) %} {# generic field "class" keyword can be used to add classes additional kwargs will be passed as attributes #} -
+
{% set cur_id = name|next_gidx %} {% if label %} {% endif %}
- + {% if icon_left %} {# we use with font from CSS instead of SVG, because using directly SVG doesn't play way with Bulma's control #} @@ -57,7 +57,7 @@ {% endmacro %} {% macro int(name, label="", init=0) %} - {{ field("number", name=name, label=label, value=init, step=1, min=0, **kwargs) }} + {{ field("number", name=name, label=label, value=init, step=1, min=0) }} {% endmacro %} {% macro checkbox(name, label="", checked=false) %} @@ -66,28 +66,28 @@ {% endmacro %} -{% macro text(name, label="", placeholder="", required=false) %} - {{ field("text", name=name, label=label, required=required, placeholder=placeholder, **kwargs) }} +{% 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}) }} {% endmacro %} -{% macro password(name, label="", required=false) %} - {{ field("password", name=name, label=label, required=required, **kwargs) }} +{% 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) }} {% endmacro %} {% macro email(name, label="", required=false) %} - {{ field("email", name=name, label=label, required=required, **kwargs) }} + {{ field("email", name=name, label=label, required=required) }} {% endmacro %} {% macro date(name, label="", required=false) %} - {{ field("date", name=name, label=label, required=required, **kwargs) }} + {{ field("date", name=name, label=label, required=required) }} {% endmacro %} -{% macro url(name, label="", required=false) %} - {{ field("url", name=name, label=label, required=required, **kwargs) }} +{% macro url(name, label="", class="", placeholder=none, required=false, title=none, pattern=none) %} +{{ field("url", name=name, label=label, required=required, attrs={'placeholder': placeholder, 'title': title, 'pattern': pattern}) }} {% endmacro %} {% macro file(name, label="", required=false) %} - {{ field("file", name=name, label=label, required=required, **kwargs) }} + {{ field("file", name=name, label=label, required=required) }} {% endmacro %} {% macro textarea(name, label="", rows=none, cols=50, placeholder='', help='', required=false) %}