Anonymous avatar Anonymous committed be6335d

[svn] content_tags and cdatas should render '' when passed None content.
ensuring so in tests
resolves: #34

Comments (0)

Files changed (2)

tests/test_form_tag.py

             '<select id="people" name="people"><option>justin</option></select>'
         )
 
+    def test_text_area(self):
+        self.assertEqual(
+            text_area("aa", ""),
+            '<textarea id="aa" name="aa"></textarea>'
+        )
+        self.assertEqual(
+            text_area("aa", None),
+            '<textarea id="aa" name="aa"></textarea>'
+        )
+        self.assertEqual(
+            text_area("aa", "Hello!"),
+            '<textarea id="aa" name="aa">Hello!</textarea>'
+        )
+
     def test_text_area_size_string(self):
         self.assertEqual(
             text_area("body", "hello world", size = "20x40"),
 
     def test_text_field(self):
         self.assertEqual(
+            text_field("title", ""),
+            '<input id="title" name="title" type="text" value="" />'
+        )
+        self.assertEqual(
+            text_field("title", None),
+            '<input id="title" name="title" type="text" />'
+        )
+        self.assertEqual(
             text_field("title", "Hello!"),
             '<input id="title" name="title" type="text" value="Hello!" />'
         )

webhelpers/rails/tags.py

         >>> content_tag("div", content_tag("p", "Hello world!"), class_="strong")
         <div class="strong"><p>Hello world!</p></div>
     """
+    if content is None:
+        content = ''
     tag = '<%s%s>%s</%s>' % (name, (options and tag_options(**options)) or '', content, name)
     return tag
 
     ``<![CDATA[`` and end with (and may not contain) the string 
     ``]]>``. 
     """
+    if content is None:
+        content = ''
     return "<![CDATA[%s]]>" % content
 
 def tag_options(**options):
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.