simple_display 0.0.1.alpha2 → 0.0.1.alpha3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +26 -3
- data/lib/simple_display/display_block.rb +5 -5
- data/lib/simple_display/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a585285f6b44df9e6461b0c30ce95bb2d0ab7ca7
|
4
|
+
data.tar.gz: a576706e0703d42d1758b983eda22d4e37dae390
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d22ad7598d4fed31856c0f2b05f635cac5e3d05bfedb17080f088a967f37c991d97521bb5043e009bee385bed2e3409303f6c893df153069953aec14d35ccb39
|
7
|
+
data.tar.gz: 5adcc77003d897002d178f260dd62a32357ad37a5cd2f6121982b71e075249f2920e093f7a90a072f1416f57c19e0d4213b5ac8f12708426c3009c808f4c9027
|
data/README.md
CHANGED
@@ -50,15 +50,38 @@ Or install it with:
|
|
50
50
|
|
51
51
|
## Usage
|
52
52
|
|
53
|
-
|
54
|
-
|
53
|
+
Simply install `simple_display` and start using it:
|
54
|
+
|
55
|
+
```erb
|
56
|
+
<%= display_for @book do |d| %>
|
57
|
+
<dl>
|
58
|
+
<%= d.display :title %>
|
59
|
+
<%= d.currency :price %>
|
60
|
+
</dl>
|
61
|
+
<% end %>
|
62
|
+
```
|
63
|
+
|
64
|
+
### Custom displayers
|
65
|
+
|
66
|
+
You can use custom displayers. Create an `app/displayers` folder in your Rails
|
67
|
+
app and add your displayers there. For instance, if you want to create an
|
68
|
+
displayer that parses a text as markdown and outputs it as HTML using the
|
69
|
+
`Kramdown` gem, you could do this:
|
70
|
+
|
71
|
+
```ruby
|
72
|
+
# app/displayers/markdown_displayer.rb
|
73
|
+
class MarkdownDisplayer < SimpleDisplay::Displayers:Base
|
74
|
+
def display_value(field_value, &block)
|
75
|
+
Kramdown::Document.new(field_value).to_html.html_safe
|
76
|
+
end
|
77
|
+
end
|
78
|
+
```
|
55
79
|
|
56
80
|
## TODO
|
57
81
|
|
58
82
|
* Add tests & docs (sorry!)
|
59
83
|
* Add more displayers
|
60
84
|
* Add more content to this README file
|
61
|
-
* Let users use custom displayers
|
62
85
|
|
63
86
|
## Contributing
|
64
87
|
|
@@ -14,9 +14,9 @@ module SimpleDisplay
|
|
14
14
|
end
|
15
15
|
|
16
16
|
def method_missing(method, *args, &block)
|
17
|
-
klass = "
|
18
|
-
|
19
|
-
|
17
|
+
klass = "#{method}_displayer".camelize
|
18
|
+
klass = SimpleDisplay::Displayers.const_get(klass)
|
19
|
+
if klass.is_a?(Class)
|
20
20
|
klass.new(model, helper).display(*args, &block)
|
21
21
|
else
|
22
22
|
super
|
@@ -24,8 +24,8 @@ module SimpleDisplay
|
|
24
24
|
end
|
25
25
|
|
26
26
|
def respond_to?(method, *args, &block)
|
27
|
-
klass = "
|
28
|
-
|
27
|
+
klass = "#{method}_displayer".camelize
|
28
|
+
klass = SimpleDisplay::Displayers.const_get(klass).is_a?(Class) || super
|
29
29
|
end
|
30
30
|
end
|
31
31
|
end
|