From 11c9c3cbcd2ce66501f0fe44cdb0964ad4ef78a7 Mon Sep 17 00:00:00 2001 From: Steven Murdoch Date: Wed, 14 Jun 2023 13:51:18 +0200 Subject: [PATCH] Fix off-by-one, improve style in forms example. --- examples/forms/templates/index.html.tera | 17 +++++++++++++---- examples/forms/templates/macros.html.tera | 10 +++++----- 2 files changed, 18 insertions(+), 9 deletions(-) diff --git a/examples/forms/templates/index.html.tera b/examples/forms/templates/index.html.tera index 78f06469..dd227b8e 100644 --- a/examples/forms/templates/index.html.tera +++ b/examples/forms/templates/index.html.tera @@ -13,16 +13,25 @@ margin: 0 auto; padding: 20px 10px; } + + h1 { + margin: 10px 0; + }

Form Example

- {% if errors | length > 1 %} - - {{ errors | length }} field(s) have errors - + {% if errors | length > 0 %} +
+
+ + error: {{ errors | length }} field{{ errors | length | pluralize }} + failed to validate + +
+
{% endif %}
diff --git a/examples/forms/templates/macros.html.tera b/examples/forms/templates/macros.html.tera index 2b0128c3..ec7144eb 100644 --- a/examples/forms/templates/macros.html.tera +++ b/examples/forms/templates/macros.html.tera @@ -2,7 +2,7 @@ {%- if name in values -%} {{- values | get(key=name) | first -}} {%- endif -%} -{% endmacro %} +{% endmacro value_for %} {% macro errors_for(name) %} {%- if name in errors -%} @@ -11,7 +11,7 @@

{{ error.msg }}

{% endfor %} {%- endif -%} -{% endmacro %} +{% endmacro errors_for %} {% macro input(type, label, name, value="") %} @@ -37,7 +37,7 @@ > {{ label }} -{% endmacro input %} +{% endmacro checkbox %} {% macro textarea(label, name, placeholder="", max=250) %} @@ -49,7 +49,7 @@ {{ self::errors_for(name=name) }} -{% endmacro input %} +{% endmacro textarea %} {% macro select(label, name, options) %} @@ -60,4 +60,4 @@ >{{ value }} {% endfor %} -{% endmacro input %} +{% endmacro select %}