Commits

Andriy Kornatskyy  committed 71619b5

Added password widget; label can have attributes

  • Participants
  • Parent commits 53c4c62

Comments (0)

Files changed (1)

File src/wheezy/html/widgets.py

     })
 
 
+def password(name, value, attrs=None):
+    """
+        >>> password('passwd', '')
+        <input type="password" id="passwd" value="" name="passwd" />
+    """
+    return Tag('input', attrs={
+            'id': id(name),
+            'name': name,
+            'type': 'password',
+            'value': value
+    })
+
+
 def textarea(name, value, attrs=None):
     """
         >>> textarea('message_text', 'x')  #doctest: +NORMALIZE_WHITESPACE
     """
         >>> label('zip_code', 'Zip Code')
         <label for="zip-code">Zip Code</label>
+        >>> label('zip_code', 'Zip Code', attrs={'class_': 'inline'})
+        <label class="inline" for="zip-code">Zip Code</label>
     """
     tag_attrs = {
             'for': id(name)
     }
+    if attrs:
+        tag_attrs.update(attrs)
     return Tag('label', inner=value, attrs=tag_attrs)
 
 
 default = {
         'hidden': hidden,
         'textbox': textbox,
+        'password': password,
         'textarea': textarea,
         'checkbox': checkbox,
         'label': label,