Class: Picky::Helper
Overview
This class provides a few view helpers.
Class Method Summary collapse
-
.cached_interface(options = {}) ⇒ Object
Returns a cached version if you always use a single language.
- .input(options = {}) ⇒ Object
-
.interface(options = {}) ⇒ Object
Returns a standard search interface for easy starting.
- .results(options = {}) ⇒ Object
Class Method Details
.cached_interface(options = {}) ⇒ Object
Returns a cached version if you always use a single language.
53 54 55 |
# File 'lib/picky-client/helper.rb', line 53 def self.cached_interface = {} @interface ||= interface().freeze end |
.input(options = {}) ⇒ Object
29 30 31 32 33 34 35 36 37 38 |
# File 'lib/picky-client/helper.rb', line 29 def self.input = {} "<form class=\"empty\" onkeypress=\"return event.keyCode != 13;\">\n<div class=\"status\"></div>\n<input type=\"search\" placeholder=\"\#{options[:placeholder] || 'Search here...'}\" autocorrect=\"off\" class=\"query\"/>\n<a class=\"reset\" title=\"clear\"></a>\n <input type=\"button\" value=\"\#{options[:button] || 'search'}\"/>\n</form>\n" end |
.interface(options = {}) ⇒ Object
Returns a standard search interface for easy starting.
... aka scaffolding ;)
Options:
- button: The search button text.
- no_results: The text shown when there are no results.
- more: The text shown when there are more than X results.
Usage, in Views:
= Picky::Helper.interface :button => 'Go go go!'
21 22 23 24 25 26 27 28 |
# File 'lib/picky-client/helper.rb', line 21 def self.interface = {} "<section class=\"picky\">\n \#{input(options)}\n \#{results(options)}\n</section>\n" end |
.results(options = {}) ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/picky-client/helper.rb', line 39 def self.results = {} "<div class=\"results\"></div>\n<div class=\"no_results\">\#{options[:no_results] || 'Sorry, no results found!'}</div>\n<div class=\"allocations\">\n <ol class=\"shown\"></ol>\n <ol class=\"more\">\#{options[:more] || 'more'}</ol>\n <ol class=\"hidden\"></ol>\n</div>\n" end |