tag_helper 0.1.0 → 0.2.0
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 +1 -3
- data/lib/tag_helper.rb +4 -11
- 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: 2b420333feaa707ac8a407a5f42a13465cb5cdf4
|
4
|
+
data.tar.gz: cd3a1fed83c4bbb9d9a3407583e1f07e089764d4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a93025b7b005d96d7be35b3e762f838755cebe473afd9c1992068be2c84256d4054aa717fd3e8e3abcc228a8c42eddd35e9adbc8c5fcd45f73b2b8b6f16e78bc
|
7
|
+
data.tar.gz: bd4120056cef2251d99271d2cc5a12b866dbf112634cd689709583b78f9a2bbfaf32ec5dda84ba984c592c2f5b190efb32c18a814bdb696f15e0802bde542eb0
|
data/README.md
CHANGED
data/lib/tag_helper.rb
CHANGED
@@ -1,5 +1,3 @@
|
|
1
|
-
require 'rexml/document'
|
2
|
-
|
3
1
|
module TagHelper
|
4
2
|
|
5
3
|
def image_tag(src, html_options = {})
|
@@ -23,10 +21,9 @@ module TagHelper
|
|
23
21
|
end
|
24
22
|
|
25
23
|
def content_tag(tag, value, attrs = {})
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
[b, v, e].join
|
24
|
+
start_tag = "<#{tag_and_attributes(tag, attributes(attrs))}>"
|
25
|
+
end_tag = "</#{tag}>"
|
26
|
+
[start_tag, value, end_tag].join
|
30
27
|
end
|
31
28
|
|
32
29
|
def tag_and_attributes(tag, attributes)
|
@@ -36,11 +33,7 @@ module TagHelper
|
|
36
33
|
def attributes(hash)
|
37
34
|
hash.to_a.
|
38
35
|
reject { |k,v| v.nil? }.
|
39
|
-
map { |k, v| %{#{k}="#{
|
40
|
-
end
|
41
|
-
|
42
|
-
def normalize(s)
|
43
|
-
REXML::Text::normalize(s)
|
36
|
+
map { |k, v| %{#{k}="#{v}"} }.join(' ')
|
44
37
|
end
|
45
38
|
|
46
39
|
extend self
|