diff --git a/MANIFEST.in b/MANIFEST.in index edca56f..48cbe91 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,6 +1,7 @@ recursive-include tw2/forms/static * recursive-include tw2/forms/templates *.py recursive-include tw2/forms/templates *.html +recursive-include tw2/forms/templates *.jinja recursive-include tw2/forms/templates *.tmpl recursive-include tw2/forms/templates *.kid recursive-include tw2/forms/templates *.mak diff --git a/tests/test_widgets.py b/tests/test_widgets.py index b3b3930..7e8ec28 100644 --- a/tests/test_widgets.py +++ b/tests/test_widgets.py @@ -28,7 +28,7 @@ class WidgetTest(_WidgetTest): the first two since those are the only templates provided by tw2.forms itself. """ - engines = ['mako', 'genshi'] + engines = ['mako', 'genshi', 'jinja'] class TestInputField(WidgetTest): diff --git a/tw2/forms/templates/calendar.jinja b/tw2/forms/templates/calendar.jinja new file mode 100644 index 0000000..65ce742 --- /dev/null +++ b/tw2/forms/templates/calendar.jinja @@ -0,0 +1,11 @@ +
+ + + +
\ No newline at end of file diff --git a/tw2/forms/templates/datagrid.jinja b/tw2/forms/templates/datagrid.jinja new file mode 100644 index 0000000..35b648d --- /dev/null +++ b/tw2/forms/templates/datagrid.jinja @@ -0,0 +1,23 @@ + + {% if w.columns %} + + + {% for i, col in enumerate(w.columns) %} + + {% endfor %} + + + {% endif %} + + + {% for i, row in enumerate(w.value) %} + + {% for col in w.columns %} + + {% endfor %} + + {% endfor %} + +
{{ col.title }}
{{ col.get_field(row) }}
\ diff --git a/tw2/forms/templates/fieldset.jinja b/tw2/forms/templates/fieldset.jinja new file mode 100644 index 0000000..248fffb --- /dev/null +++ b/tw2/forms/templates/fieldset.jinja @@ -0,0 +1,4 @@ +
+ {{ w.legend or '' }} + {{ w.child.display() }} +
diff --git a/tw2/forms/templates/form.jinja b/tw2/forms/templates/form.jinja new file mode 100644 index 0000000..76de4ab --- /dev/null +++ b/tw2/forms/templates/form.jinja @@ -0,0 +1,14 @@ +
+ {{ w.error_msg or '' }} + {% if w.help_msg %} +
+

+ {{ w.help_msg }} +

+
+ {% endif %} + {{ w.child.display() }} + {% for button in w.buttons %} + {{ button.display() }} + {% endfor %} +
diff --git a/tw2/forms/templates/grid_layout.jinja b/tw2/forms/templates/grid_layout.jinja new file mode 100644 index 0000000..6f3c88d --- /dev/null +++ b/tw2/forms/templates/grid_layout.jinja @@ -0,0 +1,13 @@ + + +{% for col in w.children[0].children_non_hidden %} + +{% endfor %} + +{% for row in w.children %} + {{ row.display }} +{% endfor %} + +
{{ col.label | string }}
+ {{ w.error_msg or '' }} +
diff --git a/tw2/forms/templates/input_field.jinja b/tw2/forms/templates/input_field.jinja new file mode 100644 index 0000000..69ceb64 --- /dev/null +++ b/tw2/forms/templates/input_field.jinja @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/tw2/forms/templates/label.jinja b/tw2/forms/templates/label.jinja new file mode 100644 index 0000000..4a1658f --- /dev/null +++ b/tw2/forms/templates/label.jinja @@ -0,0 +1 @@ +{{ w.text }} \ No newline at end of file diff --git a/tw2/forms/templates/label_field.jinja b/tw2/forms/templates/label_field.jinja new file mode 100644 index 0000000..4f18ad9 --- /dev/null +++ b/tw2/forms/templates/label_field.jinja @@ -0,0 +1 @@ +{{ w.value|string }} \ No newline at end of file diff --git a/tw2/forms/templates/link_field.jinja b/tw2/forms/templates/link_field.jinja new file mode 100644 index 0000000..c8165d5 --- /dev/null +++ b/tw2/forms/templates/link_field.jinja @@ -0,0 +1 @@ +{{ w.text }} \ No newline at end of file diff --git a/tw2/forms/templates/list_layout.jinja b/tw2/forms/templates/list_layout.jinja new file mode 100644 index 0000000..215ded7 --- /dev/null +++ b/tw2/forms/templates/list_layout.jinja @@ -0,0 +1,18 @@ + diff --git a/tw2/forms/templates/postlabeled_input_field.jinja b/tw2/forms/templates/postlabeled_input_field.jinja new file mode 100644 index 0000000..a313ec8 --- /dev/null +++ b/tw2/forms/templates/postlabeled_input_field.jinja @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/tw2/forms/templates/row_layout.jinja b/tw2/forms/templates/row_layout.jinja new file mode 100644 index 0000000..16e926a --- /dev/null +++ b/tw2/forms/templates/row_layout.jinja @@ -0,0 +1,18 @@ + + {% for c in w.children_non_hidden %} + + {{ c.display() }} + {% if c.error_msg %} + + {% endif %} + + {% endfor %} + + {% for c in w.children_hidden %} + {{ c.display() }} + {% endfor %} + {% if w.error_msg %} + + {% endif %} + + diff --git a/tw2/forms/templates/select_field.jinja b/tw2/forms/templates/select_field.jinja new file mode 100644 index 0000000..6b5dbe3 --- /dev/null +++ b/tw2/forms/templates/select_field.jinja @@ -0,0 +1,13 @@ + \ No newline at end of file diff --git a/tw2/forms/templates/selection_list.jinja b/tw2/forms/templates/selection_list.jinja new file mode 100644 index 0000000..828198c --- /dev/null +++ b/tw2/forms/templates/selection_list.jinja @@ -0,0 +1,19 @@ + \ No newline at end of file diff --git a/tw2/forms/templates/selection_table.jinja b/tw2/forms/templates/selection_table.jinja new file mode 100644 index 0000000..f1ba8f1 --- /dev/null +++ b/tw2/forms/templates/selection_table.jinja @@ -0,0 +1,17 @@ + + + {% for row in w.options_rows %} + + {% for attrs, desc in row %} + + {% endfor %} + {% for j in range(w.cols - row|length) %} + + {% endfor %} + +
+ + + + {% endfor %} +
diff --git a/tw2/forms/templates/separated_selection_table.jinja b/tw2/forms/templates/separated_selection_table.jinja new file mode 100644 index 0000000..94172bc --- /dev/null +++ b/tw2/forms/templates/separated_selection_table.jinja @@ -0,0 +1,8 @@ + + {% for attrs, desc in w.options %} + + + + + {% endfor %} +
\ No newline at end of file diff --git a/tw2/forms/templates/spacer.jinja b/tw2/forms/templates/spacer.jinja new file mode 100644 index 0000000..171e792 --- /dev/null +++ b/tw2/forms/templates/spacer.jinja @@ -0,0 +1 @@ +
 
\ No newline at end of file diff --git a/tw2/forms/templates/table_layout.jinja b/tw2/forms/templates/table_layout.jinja new file mode 100644 index 0000000..b1e7f2c --- /dev/null +++ b/tw2/forms/templates/table_layout.jinja @@ -0,0 +1,32 @@ + + {% for c in w.children_non_hidden %} + + + {% if c.label %} + + {% endif %} + + + + {% endfor %} + + +
{{ c.label }} + {{ c.display() }} + + {% if not w.hover_help %} + {{ c.help_text or '' }} + {% endif %} + {{ c.error_msg or ''}} +
+ {% for c in w.children_hidden %} + {{ c.display() }} + {% endfor %} + {{ w.error_msg or '' }} +
diff --git a/tw2/forms/templates/textarea.jinja b/tw2/forms/templates/textarea.jinja new file mode 100644 index 0000000..f162526 --- /dev/null +++ b/tw2/forms/templates/textarea.jinja @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/tw2/forms/templates/vertical_selection_table.jinja b/tw2/forms/templates/vertical_selection_table.jinja new file mode 100644 index 0000000..35a07ef --- /dev/null +++ b/tw2/forms/templates/vertical_selection_table.jinja @@ -0,0 +1,30 @@ + + {% if w.grouped_options[0][0] %} + + + {% for group_name, options in w.grouped_options %} + + {% endfor %} + + + {% endif %} + + {% for row in w.options_rows %} + + {% for attrs, desc in row %} + {% if attrs and desc %} + + {% else %} + + {% endfor %} + +
{{ group_name }}
+ + + + {% endif %} + {% endfor %} + {% for j in range(w.cols - len(row)) %} + + {% endfor %} +