[Borges-users] HTMLRenderer extension

Kaspar Schiess eule at space.ch
Mon Apr 12 14:20:13 EDT 2004


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

I propose the following extension to HTMLRenderer:

r.password_input do
~  ...
end

r.password_input_on(:password, self)

This seems to be in the pipeline but not yet implemented, so there I did
it.

kaspar - code philosopher

- -- stolen off the net --
"Those who do not understand UNIX are condemned to reinvent it -- badly."
	        -- Henry Spencer
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (MingW32)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org

iD8DBQFAenttFifl4CA0ImQRAtBzAKCniAiYHbmB7aRYnTmbAnh1K6A8kACgmMe3
LSOlS8m+ifCz9XdBGRv/eXs=
=bM4a
-----END PGP SIGNATURE-----
-------------- next part --------------
diff -r -u -b borges\lib\Borges\./HTML/HtmlRenderer.rb t\Borges\./HTML/HtmlRenderer.rb
--- borges\lib\Borges\./HTML/HtmlRenderer.rb	Mon Apr  5 03:43:00 2004
+++ t\Borges\./HTML/HtmlRenderer.rb	Mon Apr 12 12:59:35 2004
@@ -301,6 +301,25 @@
     return update_key
   end
 
+  ##
+  # Creates a password input containing +value+. It is however
+  # not a good idea to output the current password to html, since
+  # the user can retrieve it by looking at the source. 
+
+  def password_input(value = "", &callback)
+    value_input(:password, value, &callback)
+  end
+
+  ##
+  # Creates a password input that gets its value by calling +sym+ to
+  # +obj+, then calls +sym+= to +obj+ when submitted.
+
+  def password_input_on(sym, obj)
+    element_id(sym)
+    password_input(obj.send(sym), &callback_for_setter_on(sym, obj))
+  end
+    
+
 =begin
 
   def anchorWithAction_do(actionBlock, linkBlock)
diff -r -u -b borges\lib\Borges\./TestCase/HtmlRendererTest.rb t\Borges\./TestCase/HtmlRendererTest.rb
--- borges\lib\Borges\./TestCase/HtmlRendererTest.rb	Mon Apr  5 04:59:20 2004
+++ t\Borges\./TestCase/HtmlRendererTest.rb	Mon Apr 12 13:03:49 2004
@@ -213,6 +213,30 @@
   def test_option
     assert_renders("<option value=\"1\">text</option>") do |r|
       r.option("text") do end
+    end
+  end
+  
+  def test_password_input
+    expected = "<input name=\"1\" value=\"\" type=\"password\">"
+    assert_renders(expected) do |r|
+      r.password_input do end
+    end
+  end
+
+  def test_password_input_with_value
+    expected = "<input name=\"1\" value=\"text\" type=\"password\">"
+    assert_renders(expected) do |r|
+      r.password_input("text") do end
+    end
+  end
+
+  def test_password_input_on
+    obj = Object.new
+    obj.instance_eval "def foo() 'text' end"
+
+    expected = "<input id=\"foo\" name=\"1\" value=\"text\" type=\"password\">"
+    assert_renders(expected) do |r|
+      r.password_input_on :foo, obj
     end
   end
 


More information about the Borges-users mailing list