Пример #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)
Пример #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)
Пример #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)
Пример #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)
Пример #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)
Пример #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)
Пример #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)
Пример #8
0
Файл: doc.py Проект: rrva/yattag
 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)
Пример #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)
Пример #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)
Пример #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)
Пример #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)