Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 114 lines (86 sloc) 3.463 kb
5655258 @phallstrom forgot to include tests. readme
authored
1 == simple_show
2
3 * http://github.com/phallstrom/simple_show
4
5 == Description:
6
2639809 @phallstrom better copy
authored
7 SimpleShow is to #show as SimpleForm is to #edit.
5655258 @phallstrom forgot to include tests. readme
authored
8
9 == Requirements:
10
11 * Rails 3
12
13 == Install:
14
15 Add it to your Gemfile:
16
17 gem "simple_show"
18
b77bc15 @phallstrom update README
authored
19 Update your bundle:
20
21 bundle update simple_show
22
5655258 @phallstrom forgot to include tests. readme
authored
23 Run the generator:
24
25 rails generate simple_show:install
26
27 == Example Usage:
28
29 Assume we have a Person object with name, phone, email, born_on, etc.
30 In our show action we can then do this:
31
7606e65 @phallstrom f -> s
authored
32 <%= simple_show_for @johndoe do |s| %>
33 <%= s.show :name %>
34 <%= s.show :phone, :label => 'Telephone' %>
35 <%= s.show(:email) {|o| o.email.downcase} %>
36 <%= s.show :born_on, :value => '**censored**' %>
1b69bc3 @phallstrom Add :format option for date/time/string/numeric values. Fix html_safe is...
authored
37 <%= s.show :updated_at, :format => '%B %d' %>
38 <%= s.show :created_at, :format => :short # Assumes you've defined a DATE_FORMAT for :short %>
39 <%= s.show :cash_in_wallet, :format => '$%.2f' %>
01f52ed @phallstrom add support for :if/:unless options to show()
authored
40 <%= s.show :height, :if => :tall %>
41 <%= s.show :weight, :unless => :sensitive %>
5655258 @phallstrom forgot to include tests. readme
authored
42 <% end %>
43
01f52ed @phallstrom add support for :if/:unless options to show()
authored
44 Which would generate (using the defaults) output like this, assuming that
45 @johndor.tall returns false and @johndoe.sensitive returns true:
5655258 @phallstrom forgot to include tests. readme
authored
46
47 <div class="simple_show person" id="person_123">
48 <div class="show">
49 <label>Name:</label>
50 <span class="value">John Doe</span>
51 </div>
52 <div class="show">
53 <label>Telephone:</label>
54 <span class="value">867-5309</span>
55 </div>
56 <div class="show">
57 <label>Email:</label>
58 <span class="value">johndoe@example.com</span>
59 </div>
60 <div class="show">
61 <label>Born on:</label>
62 <span class="value">**censored**</span>
63 </div>
1b69bc3 @phallstrom Add :format option for date/time/string/numeric values. Fix html_safe is...
authored
64 <div class="show">
65 <label>Updated at:</label>
66 <span class="value">August 2</span>
67 </div>
68 <div class="show">
69 <label>Created at:</label>
70 <span class="value">Aug 1 2010</span>
71 </div>
72 <div class="show">
73 <label>Cash in wallet:</label>
74 <span class="value">$123.45</span>
75 </div>
5655258 @phallstrom forgot to include tests. readme
authored
76 <br clear="all">
77 </div>
78
79 == Options:
80
81 There are a number of options that control the resulting HTML.
82 See lib/simple_show.rb for what they are. For example,
83 if you don't want that BR tag then set SimpleShow.clear_on_close to false.
84
b77bc15 @phallstrom update README
authored
85 == TODO:
86
87 - Add support for associations.
1b69bc3 @phallstrom Add :format option for date/time/string/numeric values. Fix html_safe is...
authored
88 - Add options for formatting and booleans.
5655258 @phallstrom forgot to include tests. readme
authored
89
90 == License:
91
92 (The MIT License)
93
b77bc15 @phallstrom update README
authored
94 Copyright (c) 2011 Philip Hallstrom <philip@pjkh.com>
5655258 @phallstrom forgot to include tests. readme
authored
95
96 Permission is hereby granted, free of charge, to any person obtaining
97 a copy of this software and associated documentation files (the
98 'Software'), to deal in the Software without restriction, including
99 without limitation the rights to use, copy, modify, merge, publish,
100 distribute, sublicense, and/or sell copies of the Software, and to
101 permit persons to whom the Software is furnished to do so, subject to
102 the following conditions:
103
104 The above copyright notice and this permission notice shall be
105 included in all copies or substantial portions of the Software.
106
107 THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
108 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
109 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
110 IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
111 CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
112 TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
113 SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Something went wrong with that request. Please try again.