comparison sat_templates/default/input/textbox.html @ 153:b84d20af0ed3

macros (field, form, textbox): general improvments: - use a generic "field" macro for most fields - added "required" class on input labels if suitable - extra kw args are used as input field attributes. Same thing for forms - better handling of id if label is missing - added blog_text macro in textbox for basic text blog input - textbox is more customisable (class and textarea class can be specified)
author Goffi <goffi@goffi.org>
date Thu, 21 Jun 2018 01:09:00 +0200
parents 33c7ce833d3f
children
comparison
equal deleted inserted replaced
152:da2c0dc7c1ff 153:b84d20af0ed3
1 {% import 'input/form.html' as form with context %} 1 {% import 'input/form.html' as form with context %}
2 {% import 'input/field.html' as field %} 2 {% import 'input/field.html' as field with context %}
3 3
4 {% macro head(service, node, type="textbox") %} 4 {% macro head(service, node, type="textbox") %}
5 {# include data needed to identify the node to use for commenting #} 5 {# include data needed to identify the node to use for commenting #}
6 <input type="hidden" name="type" value="{{type}}"> 6 <input type="hidden" name="type" value="{{type}}">
7 <input type="hidden" name="service" value="{{service}}"> 7 <input type="hidden" name="service" value="{{service}}">
10 10
11 {% macro submit(label=_("Send")) %} 11 {% macro submit(label=_("Send")) %}
12 <input type="submit" value="{{label}}"> 12 <input type="submit" value="{{label}}">
13 {% endmacro %} 13 {% endmacro %}
14 14
15 {% macro textbox(service, node, action='', placeholder='', submit_label=_("Send"), type="textbox") %} 15 {% macro textbox(service, node, action='', placeholder='',
16 {# generic content area for comments/blog posts/etc. Only a body by default, but new elements can be 16 submit_label=_("Send"), type="textbox",
17 class='', ta_class='') %}
18 {# generic content area for comments/blog posts/etc.
19 Only a body by default, but new elements can be
17 added by using this macro with call #} 20 added by using this macro with call #}
18 {% set extra_content = caller() if caller is defined else '' %} 21 {% set extra_content = caller() if caller is defined else '' %}
19 {% call form.form(action=action, class="textbox") %} 22 {% call form.form(action=action, class="textbox " + class) %}
20 {{ head(service, node, type) }} 23 {{ head(service, node, type) }}
21 {{ extra_content }} 24 {{ extra_content }}
22 {{ field.textarea("body", placeholder=placeholder, required=True) }} 25 {{ field.textarea("body", placeholder=placeholder, required=True,
26 class=ta_class) }}
23 {{ submit(label=submit_label) }} 27 {{ submit(label=submit_label) }}
24 {% endcall %} 28 {% endcall %}
25 {% endmacro %} 29 {% endmacro %}
26 30
27 {% macro comment(service, node, action='', placeholder=_("Your comment")) %} 31 {% macro blog_text(service, node, action='', placeholder=_("Your comment")) %}
28 {{ textbox(service, node, action=action, placeholder=placeholder, type="comment") }} 32 {{ textbox(service, node, action=action, placeholder=placeholder, type="comment") }}
33 {% endmacro %}
34
35 {% macro comment(service, node, action='', placeholder=_("Your comment"), class='box--medium') %}
36 {{ textbox(service, node, action=action, placeholder=placeholder, type="comment", class=class) }}
29 {% endmacro %} 37 {% endmacro %}
30 38
31 {% macro comment_or_login(service, node, action='', placeholder=none) %} 39 {% macro comment_or_login(service, node, action='', placeholder=none) %}
32 {# show comment form a a message asking to log in 40 {# show comment form a a message asking to log in
33 login is checked using profile #} 41 login is checked using profile #}