Exemple #1
0
 def prerender(self):
     """Return a Tag or TagContent object."""
     tag = Tag('input',
               type_='text',
               name=self.name,
               value=self.value,
               id=self._id)
     tag.set_attributes(self.attributes)
     if self.label:
         if self.label.align == 'left':
             args = [self.label.label(self), ' ', tag]
         else:
             args = [tag, ' ', self.label.label(self)]
         tag = TagContent(*args)
     if self.wrapper:
         tag = self.wrapper.wrap(tag, self)
     return tag
Exemple #2
0
 def test_tag_with_tagcontent(self):
     self.assertEqual(
         Tag('p', TagContent('Hello world')).render(), '<p>Hello world</p>')
Exemple #3
0
 def test_mixed_tag_content(self):
     self.assertEqual(
         TagContent('hello', SomeHtml(), 'world').render(),
         'hello<html>world')
Exemple #4
0
    def test_html_tag_content(self):

        self.assertEqual(TagContent(SomeHtml()).render(), '<html>')
Exemple #5
0
 def test_string_tag_content_escape(self):
     self.assertEqual(
         TagContent('<hello>', '&world').render(),
         '&lt;hello&gt;&amp;world')
Exemple #6
0
 def test_multi_string_tag_content(self):
     self.assertEqual(TagContent('hello', 'world').render(), 'helloworld')
Exemple #7
0
    def test_string_tag_content(self):
        self.assertEqual(TagContent('test').render(), 'test')

        self.assertEqual(TagContent('test').__html__(), 'test')
Exemple #8
0
 def wrap(self, tag, field):
     if self.align == 'left':
         args = [self.text, ' ', tag]
     else:
         args = [tag, ' ', self.text]
     return Tag('label', TagContent(*args), for_=field.id)