rhtml 0.0.9 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/rhtml/html.rb +17 -18
- data/lib/rhtml/version.rb +1 -1
- metadata +2 -2
data/lib/rhtml/html.rb
CHANGED
@@ -1,36 +1,36 @@
|
|
1
1
|
module Rhtml
|
2
2
|
class Html
|
3
3
|
def initialize(content='', indent=0, &b)
|
4
|
-
@
|
5
|
-
@
|
6
|
-
@
|
7
|
-
@
|
8
|
-
|
4
|
+
@__indent = 0
|
5
|
+
@__content = content
|
6
|
+
@__cls = nil
|
7
|
+
@__id = nil
|
8
|
+
instance_eval(&b) if block_given?
|
9
9
|
end
|
10
10
|
|
11
11
|
def tag!(tag_name, ps={}, str=nil, &b)
|
12
12
|
str, ps = ps, {} if ps.is_a? String
|
13
|
-
ps[:class] = @
|
14
|
-
ps[:id] = @
|
13
|
+
ps[:class] = @__cls if @__cls
|
14
|
+
ps[:id] = @__id if @__id
|
15
15
|
|
16
|
-
@
|
17
|
-
@
|
16
|
+
@__content << Rhtml.tag_open(tag_name, ps, @__indent)
|
17
|
+
@__cls = @__id = nil
|
18
18
|
|
19
|
-
@
|
19
|
+
@__indent += 1
|
20
20
|
if str
|
21
|
-
@
|
21
|
+
@__content << INDENT * @__indent << str << "\n"
|
22
22
|
elsif block_given?
|
23
23
|
ret = instance_eval &b
|
24
|
-
@
|
24
|
+
@__content << INDENT * @__indent << ret.to_s << "\n" if ret.is_a?(String)
|
25
25
|
end
|
26
|
-
@
|
26
|
+
@__indent -= 1
|
27
27
|
|
28
|
-
@
|
28
|
+
@__content << Rhtml.tag_close(tag_name, @__indent)
|
29
29
|
self
|
30
30
|
end
|
31
31
|
|
32
32
|
def void_tag!(tag_name, ps={})
|
33
|
-
@
|
33
|
+
@__content << Rhtml.void_tag(tag_name, ps, @__indent)
|
34
34
|
self
|
35
35
|
end
|
36
36
|
|
@@ -47,13 +47,12 @@ module Rhtml
|
|
47
47
|
end
|
48
48
|
|
49
49
|
def raw! string=''
|
50
|
-
@
|
51
|
-
self
|
50
|
+
@__content << string.to_s << "\n"
|
52
51
|
end
|
53
52
|
alias_method :==, :raw!
|
54
53
|
|
55
54
|
def to_s
|
56
|
-
@
|
55
|
+
@__content
|
57
56
|
end
|
58
57
|
end
|
59
58
|
end
|
data/lib/rhtml/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rhtml
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-
|
12
|
+
date: 2013-08-05 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|