예제 #1
0
파일: doc.py 프로젝트: leforestier/yattag
 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)
예제 #2
0
파일: doc.py 프로젝트: leforestier/yattag
    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)
예제 #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)
예제 #4
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)
예제 #5
0
파일: doc.py 프로젝트: 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)
예제 #6
0
파일: doc.py 프로젝트: mschmie/yattag
    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)
예제 #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)
예제 #8
0
파일: doc.py 프로젝트: leforestier/yattag
    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)
예제 #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)
예제 #10
0
파일: doc.py 프로젝트: 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)
예제 #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
파일: doc.py 프로젝트: 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)
예제 #13
0
파일: doc.py 프로젝트: 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)