Mercurial > libervia-templates
changeset 58:4347910cc594
input(xmlui): added attributes argument to create:
specific attributes can be used of named widget (for some widget converted to <input> only so far).
The argument is a dict from widget name to a sub dict containing the keyword arguments.
The next dict_ext filter is used.
author | Goffi <goffi@goffi.org> |
---|---|
date | Thu, 09 Nov 2017 08:05:23 +0100 |
parents | 50957f0669b9 |
children | 232eb1b4cd89 |
files | default/input/xmlui.html |
diffstat | 1 files changed, 6 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/default/input/xmlui.html Sun Nov 05 23:38:09 2017 +0100 +++ b/default/input/xmlui.html Thu Nov 09 08:05:23 2017 +0100 @@ -37,13 +37,14 @@ {% endmacro %} -{% macro generate(xmlui, form=true, filters=none) %} +{% macro generate(xmlui, form=true, filters=none, attributes=none) %} {# generate HTML from XMLUI @param xmlui(template_xmlui.XMLUIPanel): xmlui to use @param form(bool): if true will generate form elements @param filters(dict,none): filters as expected by item_filter + @param attributes(dict,none): extra attributes to put on named widgets #} - {% set config = {'form':form, 'filters':filters or {}} %} + {% set config = {'form':form, 'filters':filters or {}, 'attrs': attributes or {}} %} {{ generate_container(xmlui.main_cont, config) }} {% endmacro %} @@ -143,7 +144,7 @@ {% macro string_widget(wid, config, id=none) %} {% if config.form %} - <input class="xmlui_widget xmlui_string" type="text" {{ {'name':wid.name, 'id':id, 'value':wid|item_filter(config.filters)}|xmlattr }}> + <input class="xmlui_widget xmlui_string" type="text" {{ {'name':wid.name, 'id':id, 'value':wid|item_filter(config.filters)}|dict_ext(config.attrs, wid.name)|xmlattr }}> {% else %} <div class="xmlui_widget xmlui_string" {{ {'id':id}|xmlattr }}> {{- wid|item_filter(config.filters)|default('\u00A0',true) -}} @@ -153,7 +154,7 @@ {% macro textbox_widget(wid, config, id=none) %} {% if config.form %} - <textarea class="xmlui_widget xmlui_textbox" rows="10" cols="50" {{ {'name':wid.name, 'id':id}|xmlattr }}> + <textarea class="xmlui_widget xmlui_textbox" rows="10" cols="50" {{ {'name':wid.name, 'id':id}|dict_ext(config.attrs, wid.name)|xmlattr }}> {{- wid|item_filter(config.filters) -}} </textarea> {% else %} @@ -165,7 +166,7 @@ {% macro list_widget(wid, config, id=none) %} {% if config.form %} - <select class="xmlui_widget xmlui_list" {{ {'name':wid.name, 'id':id}|xmlattr }}> + <select class="xmlui_widget xmlui_list" {{ {'name':wid.name, 'id':id}|dict_ext(config.attrs, wid.name)|xmlattr }}> {% for value,label in wid.options %} <option {{ {'value':value}|xmlattr }} {{ 'selected' if value in wid.selected }}> {{- label -}}