Exemplo n.º 1
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)
Exemplo n.º 2
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)
Exemplo n.º 3
0
 def render(self, defaults, errors, inner_content):
     selected = ''
     if self.name in defaults:
         if self.multiple:
             if self.value in defaults[self.name]:
                 selected = True
         else:
             if self.value == defaults[self.name]:
                 selected = True
     lst = ['<option value="', attr_escape(self.value), '"']
     if selected:
         lst.append(' selected="selected"')
     if self.attrs:
         lst.append(' ')
         lst.append(dict_to_attrs(self.attrs))
     lst.append('>')
     lst.append(inner_content)
     lst.append('</option>')
     return ''.join(lst)
Exemplo n.º 4
0
Arquivo: doc.py Projeto: 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)
Exemplo n.º 5
0
Arquivo: doc.py Projeto: rrva/yattag
 def render(self, defaults, errors, inner_content):
     selected = ''        
     if self.name in defaults:
         if self.multiple:
             if self.value in defaults[self.name]:
                 selected = True
         else:
             if self.value == defaults[self.name]:
                 selected = True
     lst = ['<option value="', attr_escape(self.value), '"']
     if selected:
         lst.append(' selected="selected"')
     if self.attrs:
         lst.append(' ')
         lst.append(dict_to_attrs(self.attrs))
     lst.append('>')
     lst.append(inner_content)
     lst.append('</option>')
     return ''.join(lst)
Exemplo n.º 6
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)
Exemplo n.º 7
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)
Exemplo n.º 8
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)
Exemplo n.º 9
0
 def render(self, defaults, errors, error_wrapper):
     lst = []
     attrs = dict(self.attrs)
     error = errors and self.name in errors
     if error:
         if 'class' in attrs:
             attrs['class'] = attrs['class'] + " error"
         else:
             attrs['class'] = "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)
Exemplo n.º 10
0
Arquivo: doc.py Projeto: sirex/yattag
    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)
Exemplo n.º 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)
Exemplo n.º 12
0
Arquivo: doc.py Projeto: tcler/yattag
    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)
Exemplo n.º 13
0
Arquivo: doc.py Projeto: tcler/yattag
    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)