sculpt 0.1 → 0.1.01
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/sculpt/elements.rb +9 -16
- metadata +2 -2
data/lib/sculpt/elements.rb
CHANGED
@@ -3,33 +3,26 @@ class Tag < ElementContainer
|
|
3
3
|
|
4
4
|
attr_accessor :name, :text, :attrs, :singelton, :inline
|
5
5
|
|
6
|
-
def initialize(name,text = '', attrs = {}
|
6
|
+
def initialize(name, text = '', attrs = {}, &block)
|
7
7
|
@name = name
|
8
8
|
@attrs = {}
|
9
9
|
@elements = []
|
10
10
|
@inline = false
|
11
|
+
@text = ''
|
11
12
|
|
12
|
-
if text.kind_of?
|
13
|
-
if attrs.kind_of? Tag
|
14
|
-
@inline = attrs
|
15
|
-
@elements << attrs
|
16
|
-
return self
|
17
|
-
else
|
18
|
-
@attrs = attrs
|
19
|
-
@attrs.merge!(text)
|
20
|
-
@text = '' # otherwise stays nil
|
21
|
-
end
|
22
|
-
elsif text.kind_of?(Tag)
|
13
|
+
if text.kind_of? Tag
|
23
14
|
@inline = text
|
24
15
|
@elements << text
|
25
|
-
@
|
26
|
-
@attrs = attrs
|
16
|
+
@attrs.merge!(attrs) if attrs.kind_of? Hash
|
27
17
|
return self
|
28
|
-
|
18
|
+
elsif text.kind_of? Hash
|
19
|
+
@attrs.merge!(text)
|
20
|
+
elsif text.kind_of? String
|
29
21
|
@text = text
|
30
|
-
@attrs = attrs
|
31
22
|
end
|
32
23
|
|
24
|
+
@attrs.merge!(attrs) if attrs.kind_of? Hash
|
25
|
+
|
33
26
|
if block_given?
|
34
27
|
@elements += elements_from_block(&block)
|
35
28
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sculpt
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 0.1.01
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -11,7 +11,7 @@ bindir: bin
|
|
11
11
|
cert_chain: []
|
12
12
|
date: 2012-06-10 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
|
-
description: ! "Sculpt is an HTML generator in Ruby.\n Syntax is everything"
|
14
|
+
description: ! "Sculpt is an HTML generator in Ruby.\n Syntax is everything."
|
15
15
|
email: lexy0202@gmail.com
|
16
16
|
executables: []
|
17
17
|
extensions: []
|