Permalink
Browse files

added utility helper methods

  • Loading branch information...
1 parent 291df06 commit 7c0efa039b3951977046d07a1ca3537128f97667 @paolodona paolodona committed Apr 15, 2009
Showing with 28 additions and 0 deletions.
  1. +5 −0 lib/widgets.rb
  2. +23 −0 lib/widgets/utils_helper.rb
View
5 lib/widgets.rb
@@ -40,3 +40,8 @@
##### Spiffy Corners #####
require 'widgets/spiffy_corners/spiffy_corners_helper'
ActionController::Base.helper Widgets::SpiffyCorners::SpiffyCornersHelper
+
+##### UtilsHelper #####
+require 'widgets/utils_helper'
+ActionController::Base.helper Widgets::UtilsHelper
+
View
23 lib/widgets/utils_helper.rb
@@ -0,0 +1,23 @@
+module Widgets
+ module UtilsHelper
+ def nocr(string)
+ return string.gsub("\n", '')
+ end
+
+ # converts blank spaces into no breaking spaces
+ # use it like <%=nbsp ...%>
+ def nbsp(string)
+ string.to_s.gsub " ", "&nbsp;"
+ end
+
+ # generates random text to fill up not-yet-implemented interfaces
+ def lorem(n=nil)
+ words = %w{Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.}
+ if n
+ while (n > words.size) do words = words + words; end
+ words = words[0..n]
+ end
+ return words.join(' ')
+ end
+ end
+end

0 comments on commit 7c0efa0

Please sign in to comment.