Exemple #1
0
    def render(self, defaults, errors, error_wrapper, inner_content = ''):
        lst = []
        attrs = dict(self.attrs)
        if errors and self.name in errors:
            lst.append(error_wrapper[0])
            lst.append(html_escape(errors[self.name]))
            lst.append(error_wrapper[1])
            _add_class(attrs, 'error')
        attrs['name'] = self.name

        lst.append('<%s %s>' % (self.__class__.tag_name, dict_to_attrs(attrs)))
        if self.name in defaults:
            lst.append(html_escape(str(defaults[self.name])))
        else:
            lst.append(inner_content)
        
        lst.append('</%s>' % self.__class__.tag_name)

        return ''.join(lst)
Exemple #2
0
    def render(self, defaults, errors, error_wrapper, inner_content=''):
        lst = []
        attrs = dict(self.attrs)
        if errors and self.name in errors:
            lst.append(error_wrapper[0])
            lst.append(html_escape(errors[self.name]))
            lst.append(error_wrapper[1])
            _add_class(attrs, 'error')
        attrs['name'] = self.name

        lst.append('<%s %s>' % (self.__class__.tag_name, dict_to_attrs(attrs)))
        if self.name in defaults:
            lst.append(html_escape(str(defaults[self.name])))
        else:
            lst.append(inner_content)

        lst.append('</%s>' % self.__class__.tag_name)

        return ''.join(lst)
Exemple #3
0
    def render(self, defaults, errors, error_wrapper, inner_content=""):
        lst = []
        attrs = dict(self.attrs)
        if errors:
            if self.name in errors:
                lst.append(error_wrapper[0])
                lst.append(html_escape(errors[self.name]))
                lst.append(error_wrapper[1])
            if "class" not in attrs:
                attrs["class"] = "error"
        attrs["name"] = self.name

        lst.append("<%s %s>" % (self.__class__.tag_name, dict_to_attrs(attrs)))
        if self.name in defaults:
            lst.append(html_escape(str(defaults[self.name])))
        else:
            lst.append(inner_content)

        lst.append("</%s>" % self.__class__.tag_name)

        return "".join(lst)
Exemple #4
0
 def render(self, defaults, errors, error_wrapper, stag_end = ' />'):
     lst = []
     attrs = dict(self.attrs)
     error = errors and self.name in errors
     if error:
         _add_class(attrs, 'error')
         lst.append(error_wrapper[0])
         lst.append(html_escape(errors[self.name]))
         lst.append(error_wrapper[1])
             
     if self.name in defaults:
         attrs['value'] = str(defaults[self.name])
     attrs['name'] = self.name
     lst.append('<input type="%s" %s%s' % (self.tpe, dict_to_attrs(attrs), stag_end))
     
     return ''.join(lst)
Exemple #5
0
    def render(self, defaults, errors, error_wrapper):
        lst = []
        attrs = dict(self.attrs)
        error = errors and self.name in errors
        if error:
            _add_class(attrs, 'error')
            lst.append(error_wrapper[0])
            lst.append(html_escape(errors[self.name]))
            lst.append(error_wrapper[1])

        if self.name in defaults:
            attrs['value'] = str(defaults[self.name])
        attrs['name'] = self.name
        lst.append('<input type="%s" %s />' % (self.tpe, dict_to_attrs(attrs)))

        return ''.join(lst)
Exemple #6
0
 def render(self, defaults, errors, error_wrapper, stag_end = ' />'):
     # type: (Dict[str, str], Dict[str, str], Tuple[str, str], str) -> str
     lst = [] # List[str]
     attrs = dict(self.attrs)
     error = errors and self.name in errors
     if error:
         _add_class(attrs, 'error')
         lst.append(error_wrapper[0])
         lst.append(html_escape(errors[self.name]))
         lst.append(error_wrapper[1])
             
     if self.name in defaults:
         attrs['value'] = str(defaults[self.name])
     attrs['name'] = self.name
     lst.append('<input type="%s" %s%s' % (self.tpe, dict_to_attrs(attrs), stag_end))
     
     return ''.join(lst)
Exemple #7
0
    def render(self, defaults, errors, error_wrapper, stag_end = ' />'):
        lst = []
        attrs = dict(self.attrs)
        if self.rank == 0:
            if errors and self.name in errors:
                lst.append(error_wrapper[0])
                lst.append(html_escape(errors[self.name]))
                lst.append(error_wrapper[1])
                _add_class(attrs, 'error')
        
        if self.checked(defaults):
            attrs['checked'] = 'checked'
                
        attrs['name'] = self.name
        
        lst.append('<input type="%s" %s%s' % (self.__class__.tpe, dict_to_attrs(attrs), stag_end))

        return ''.join(lst)
Exemple #8
0
 def render(self, defaults, errors, error_wrapper):
     lst = []
     attrs = dict(self.attrs)
     error = errors and self.name in errors
     if error:
         if 'klass' in attrs:
             attrs['klass'] = attrs['klass'] + " error"
         else:
             attrs['klass'] = "error"
         lst.append(error_wrapper[0])
         lst.append(html_escape(errors[self.name]))
         lst.append(error_wrapper[1])
             
     if self.name in defaults:
         attrs['value'] = str(defaults[self.name])
     attrs['name'] = self.name
     lst.append('<input type="%s" %s />' % (self.tpe, dict_to_attrs(attrs)))
     
     return ''.join(lst)
Exemple #9
0
    def render(self, defaults, errors, error_wrapper, stag_end = ' />'):
        # type: (Dict[str, Union[List[str], str]], Any, Tuple[str, str], str) -> str
        lst = []
        attrs = dict(self.attrs)
        if self.rank == 0:
            if errors and self.name in errors:
                lst.append(error_wrapper[0])
                lst.append(html_escape(errors[self.name]))
                lst.append(error_wrapper[1])
                _add_class(attrs, 'error')
        
        if self.checked(defaults):
            attrs['checked'] = 'checked'
                
        attrs['name'] = self.name
        
        lst.append('<input type="%s" %s%s' % (self.__class__.tpe, dict_to_attrs(attrs), stag_end))

        return ''.join(lst)
Exemple #10
0
    def render(self, defaults, errors, error_wrapper):
        lst = []
        attrs = dict(self.attrs)
        if self.rank == 0:
            if errors:
                if self.name in errors:
                    lst.append(error_wrapper[0])
                    lst.append(html_escape(errors[self.name]))
                    lst.append(error_wrapper[1])
                    attrs['class'].add('error')
        
        if self.name in defaults and 'value' in self.attrs and defaults[self.name] == self.attrs['value']:
            attrs['checked'] = 'checked'
                
        attrs['name'] = self.name
        
        lst.append('<input type="%s" %s />' % (self.__class__.tpe, dict_to_attrs(attrs)))

        return ''.join(lst)
Exemple #11
0
    def render(self, defaults, errors, error_wrapper):
        lst = []
        attrs = dict(self.attrs)
        if self.rank == 0:
            if errors:
                if self.name in errors:
                    lst.append(error_wrapper[0])
                    lst.append(html_escape(errors[self.name]))
                    lst.append(error_wrapper[1])
                    if 'class' not in attrs:
                        attrs['class'] = "error"
        
        if self.name in defaults and 'value' in self.attrs and defaults[self.name] == self.attrs['value']:
            attrs['checked'] = 'checked'
                
        attrs['name'] = self.name
        
        lst.append('<input type="%s" %s />' % (self.__class__.tpe, dict_to_attrs(attrs)))

        return ''.join(lst)
Exemple #12
0
    def render(self, defaults, errors, error_wrapper):
        lst = []
        attrs = dict(self.attrs)
        if self.rank == 0:
            if errors:
                if self.name in errors:
                    lst.append(error_wrapper[0])
                    lst.append(html_escape(errors[self.name]))
                    lst.append(error_wrapper[1])
                    if "class" not in attrs:
                        attrs["class"] = "error"

        if self.name in defaults and "value" in self.attrs and defaults[self.name] == self.attrs["value"]:
            attrs["checked"] = "checked"

        attrs["name"] = self.name

        lst.append('<input type="%s" %s />' % (self.__class__.tpe, dict_to_attrs(attrs)))

        return "".join(lst)