Example #1
0
    def test_special_boolean_html_attrs(self):
        s = attrs(fake_context, attrs={'checked': True})
        self.assertEqual(s, u'checked="checked"')

        s = attrs(fake_context, attrs={'checked': False})
        self.assertEqual(s, u'')

        s = attrs(fake_context, attrs={'checked': None})
        self.assertEqual(s, u'')
Example #2
0
    def test_special_boolean_html_attrs(self):
        s = attrs(fake_context, attrs={'checked':True})
        self.assertEqual(s, u'checked="checked"')

        s = attrs(fake_context, attrs={'checked':False})
        self.assertEqual(s, u'')

        s = attrs(fake_context, attrs={'checked':None})
        self.assertEqual(s, u'')
Example #3
0
def etree(context, tagname, attrs, content):

    starttag = ""
    endtag = ""

    if tagname:
        if attrs:
            starttag = "<%s %s>" % (tagname, tw2_mu.attrs(context, attrs=attrs))
        else:
            starttag = "<%s>" % tagname

        if tagname in ("input", "br", "hr", "img"):
            endtag = ""
        else:
            endtag = "</%s>" % tagname

    c = ""
    if isinstance(content, list):
        c = "".join([etree(context, *entry)  for entry in content])
    elif isinstance(content, tuple):
        c = etree(context, *content)
    elif content:
        #c = Markup(content)
        c = content

    element = starttag + c + endtag
    #log.debug("**** element=" + element)

        
    return  element
       
Example #4
0
def etree(context, tagname, attrs, content):

    starttag = ""
    endtag = ""

    if tagname:
        if attrs:
            starttag = "<%s %s>" % (tagname, tw2_mu.attrs(context, attrs=attrs))
        else:
            starttag = "<%s>" % tagname

        if tagname in ("input", "br", "hr", "img"):
            endtag = ""
        else:
            endtag = "</%s>" % tagname

    c = ""
    if isinstance(content, list):
        c = "".join([etree(context, *entry)  for entry in content])
    elif isinstance(content, tuple):
        c = etree(context, *content)
    elif content:
        #c = Markup(content)
        c = content

    element = starttag + c + endtag
    #log.debug("**** element=" + element)

        
    return  element
Example #5
0
 def test_normal_attrs(self):
     s = attrs(fake_context, attrs={'a': 5, 'b': 3})
     self.failUnless(s == u'a="5" b="3"' or s == u'b="3" a="5"')
Example #6
0
 def test_none_attrs(self):
     """Attributes with None values are not rendered"""
     s = attrs(fake_context, attrs={'a': 'hello', 'b': None})
     self.assertEqual(s, u'a="hello"')
Example #7
0
 def test_boolean_attrs(self):
     s = attrs(fake_context, attrs={'a': True, 'b': False})
     self.failUnless(s == u'a="True" b="False"'
                     or s == u'b="False" a="True"')
Example #8
0
 def test_normal_attrs(self):
     s = attrs(fake_context, attrs={'a':5, 'b':3})
     self.failUnless(s == u'a="5" b="3"' or s == u'b="3" a="5"')
Example #9
0
 def test_none_attrs(self):
     """Attributes with None values are not rendered"""
     s = attrs(fake_context, attrs={'a':'hello', 'b':None})
     self.assertEqual(s, u'a="hello"')
Example #10
0
 def test_boolean_attrs(self):
     s = attrs(fake_context, attrs={'a':True, 'b':False})
     self.failUnless(s == u'a="True" b="False"' or s == u'b="False" a="True"')
Example #11
0
 def test_normal_attrs_as_args(self):
     s = attrs(fake_context, {'a':5, 'b':3})
     self.failUnless(s == six.u('a="5" b="3"') or s == six.u('b="3" a="5"'))