Mercurial > libervia-templates
comparison default/input/xmlui.html @ 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 | d58fdd57df49 |
children | dd15b6c0b1d3 |
comparison
equal
deleted
inserted
replaced
57:50957f0669b9 | 58:4347910cc594 |
---|---|
35 {% endif %} | 35 {% endif %} |
36 {% endfor %} | 36 {% endfor %} |
37 | 37 |
38 {% endmacro %} | 38 {% endmacro %} |
39 | 39 |
40 {% macro generate(xmlui, form=true, filters=none) %} | 40 {% macro generate(xmlui, form=true, filters=none, attributes=none) %} |
41 {# generate HTML from XMLUI | 41 {# generate HTML from XMLUI |
42 @param xmlui(template_xmlui.XMLUIPanel): xmlui to use | 42 @param xmlui(template_xmlui.XMLUIPanel): xmlui to use |
43 @param form(bool): if true will generate form elements | 43 @param form(bool): if true will generate form elements |
44 @param filters(dict,none): filters as expected by item_filter | 44 @param filters(dict,none): filters as expected by item_filter |
45 @param attributes(dict,none): extra attributes to put on named widgets | |
45 #} | 46 #} |
46 {% set config = {'form':form, 'filters':filters or {}} %} | 47 {% set config = {'form':form, 'filters':filters or {}, 'attrs': attributes or {}} %} |
47 {{ generate_container(xmlui.main_cont, config) }} | 48 {{ generate_container(xmlui.main_cont, config) }} |
48 {% endmacro %} | 49 {% endmacro %} |
49 | 50 |
50 {% macro generate_table(xmlui_items, fields, formatters, tr_class_fields, on_click) %} | 51 {% macro generate_table(xmlui_items, fields, formatters, tr_class_fields, on_click) %} |
51 {# generate a HTML table from requested widgets names | 52 {# generate a HTML table from requested widgets names |
141 {% endif %} | 142 {% endif %} |
142 {% endmacro%} | 143 {% endmacro%} |
143 | 144 |
144 {% macro string_widget(wid, config, id=none) %} | 145 {% macro string_widget(wid, config, id=none) %} |
145 {% if config.form %} | 146 {% if config.form %} |
146 <input class="xmlui_widget xmlui_string" type="text" {{ {'name':wid.name, 'id':id, 'value':wid|item_filter(config.filters)}|xmlattr }}> | 147 <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 }}> |
147 {% else %} | 148 {% else %} |
148 <div class="xmlui_widget xmlui_string" {{ {'id':id}|xmlattr }}> | 149 <div class="xmlui_widget xmlui_string" {{ {'id':id}|xmlattr }}> |
149 {{- wid|item_filter(config.filters)|default('\u00A0',true) -}} | 150 {{- wid|item_filter(config.filters)|default('\u00A0',true) -}} |
150 </div> | 151 </div> |
151 {% endif %} | 152 {% endif %} |
152 {% endmacro%} | 153 {% endmacro%} |
153 | 154 |
154 {% macro textbox_widget(wid, config, id=none) %} | 155 {% macro textbox_widget(wid, config, id=none) %} |
155 {% if config.form %} | 156 {% if config.form %} |
156 <textarea class="xmlui_widget xmlui_textbox" rows="10" cols="50" {{ {'name':wid.name, 'id':id}|xmlattr }}> | 157 <textarea class="xmlui_widget xmlui_textbox" rows="10" cols="50" {{ {'name':wid.name, 'id':id}|dict_ext(config.attrs, wid.name)|xmlattr }}> |
157 {{- wid|item_filter(config.filters) -}} | 158 {{- wid|item_filter(config.filters) -}} |
158 </textarea> | 159 </textarea> |
159 {% else %} | 160 {% else %} |
160 <p class="xmlui_widget xmlui_textbox" {{ {'id':id}|xmlattr }}> | 161 <p class="xmlui_widget xmlui_textbox" {{ {'id':id}|xmlattr }}> |
161 {{- wid|item_filter(config.filters) -}} | 162 {{- wid|item_filter(config.filters) -}} |
163 {% endif %} | 164 {% endif %} |
164 {% endmacro%} | 165 {% endmacro%} |
165 | 166 |
166 {% macro list_widget(wid, config, id=none) %} | 167 {% macro list_widget(wid, config, id=none) %} |
167 {% if config.form %} | 168 {% if config.form %} |
168 <select class="xmlui_widget xmlui_list" {{ {'name':wid.name, 'id':id}|xmlattr }}> | 169 <select class="xmlui_widget xmlui_list" {{ {'name':wid.name, 'id':id}|dict_ext(config.attrs, wid.name)|xmlattr }}> |
169 {% for value,label in wid.options %} | 170 {% for value,label in wid.options %} |
170 <option {{ {'value':value}|xmlattr }} {{ 'selected' if value in wid.selected }}> | 171 <option {{ {'value':value}|xmlattr }} {{ 'selected' if value in wid.selected }}> |
171 {{- label -}} | 172 {{- label -}} |
172 </option> | 173 </option> |
173 {% endfor %} | 174 {% endfor %} |