diff farol/templates/macros.j2 @ 126:e0830bcab004

Add (optional) regex matching to our input fields
author Benoît Allard <benoit.allard@greenbone.net>
date Thu, 23 Oct 2014 16:32:33 +0200
parents 09915cbdf549
children 79abdecb2d0b
line wrap: on
line diff
--- a/farol/templates/macros.j2	Thu Oct 23 16:18:30 2014 +0200
+++ b/farol/templates/macros.j2	Thu Oct 23 16:32:33 2014 +0200
@@ -23,7 +23,7 @@
 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
 -#}
 
-{% macro textinput(name, label, placeholder="", value=None, required=False, type="text", extras={}, help='') %}
+{% macro textinput(name, label, placeholder="", value=None, required=False, type="text", extras={}, help='', regex=None) %}
 <div class="form-group">
   {% if caller %}
     {% set content=caller () %}
@@ -42,6 +42,7 @@
      id="{{ name }}" name="{{ name }}"
      {%- if placeholder %} placeholder="{{ placeholder }}"{% endif %}
      {%- if value %} value="{{ value }}"{% endif %}
+     {%- if regex %} pattern="{{ regex }}"{% endif %}
      {%- if required %} required{% endif %}
      {{- extras | xmlattr }}>
   {% if type == "datetime" %}

http://farol.wald.intevation.org