Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 111 lines (83 sloc) 3.296 kB
5655258 @phallstrom forgot to include tests. readme
authored
1 == simple_show
2
3 * http://github.com/phallstrom/simple_show
4
5 == Description:
6
7 SimpleShow is to #show as SimpleForm is to #new/#edit.
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…
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' %>
5655258 @phallstrom forgot to include tests. readme
authored
40 <% end %>
41
42 Which would generate (using the defaults) output like this:
43
44 <div class="simple_show person" id="person_123">
45 <div class="show">
46 <label>Name:</label>
47 <span class="value">John Doe</span>
48 </div>
49 <div class="show">
50 <label>Telephone:</label>
51 <span class="value">867-5309</span>
52 </div>
53 <div class="show">
54 <label>Email:</label>
55 <span class="value">johndoe@example.com</span>
56 </div>
57 <div class="show">
58 <label>Born on:</label>
59 <span class="value">**censored**</span>
60 </div>
1b69bc3 @phallstrom Add :format option for date/time/string/numeric values. Fix html_safe…
authored
61 <div class="show">
62 <label>Updated at:</label>
63 <span class="value">August 2</span>
64 </div>
65 <div class="show">
66 <label>Created at:</label>
67 <span class="value">Aug 1 2010</span>
68 </div>
69 <div class="show">
70 <label>Cash in wallet:</label>
71 <span class="value">$123.45</span>
72 </div>
5655258 @phallstrom forgot to include tests. readme
authored
73 <br clear="all">
74 </div>
75
76 == Options:
77
78 There are a number of options that control the resulting HTML.
79 See lib/simple_show.rb for what they are. For example,
80 if you don't want that BR tag then set SimpleShow.clear_on_close to false.
81
b77bc15 @phallstrom update README
authored
82 == TODO:
83
84 - Add support for associations.
1b69bc3 @phallstrom Add :format option for date/time/string/numeric values. Fix html_safe…
authored
85 - Add options for formatting and booleans.
5655258 @phallstrom forgot to include tests. readme
authored
86
87 == License:
88
89 (The MIT License)
90
b77bc15 @phallstrom update README
authored
91 Copyright (c) 2011 Philip Hallstrom <philip@pjkh.com>
5655258 @phallstrom forgot to include tests. readme
authored
92
93 Permission is hereby granted, free of charge, to any person obtaining
94 a copy of this software and associated documentation files (the
95 'Software'), to deal in the Software without restriction, including
96 without limitation the rights to use, copy, modify, merge, publish,
97 distribute, sublicense, and/or sell copies of the Software, and to
98 permit persons to whom the Software is furnished to do so, subject to
99 the following conditions:
100
101 The above copyright notice and this permission notice shall be
102 included in all copies or substantial portions of the Software.
103
104 THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
105 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
106 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
107 IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
108 CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
109 TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
110 SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Something went wrong with that request. Please try again.