simple_table 0.0.15 → 0.0.16
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/simple_table/body.rb +7 -4
- data/lib/simple_table/foot.rb +5 -1
- data/lib/simple_table/head.rb +6 -1
- data/lib/simple_table/row.rb +10 -4
- data/lib/simple_table/rows.rb +0 -5
- data/lib/simple_table/version.rb +1 -1
- metadata +3 -3
data/lib/simple_table/body.rb
CHANGED
@@ -2,10 +2,13 @@ module SimpleTable
|
|
2
2
|
class Body < Rows
|
3
3
|
self.tag_name = :tbody
|
4
4
|
|
5
|
-
def
|
6
|
-
|
7
|
-
|
8
|
-
|
5
|
+
def render
|
6
|
+
build
|
7
|
+
super(''.tap do |html|
|
8
|
+
table.collection.each_with_index do |record, ix|
|
9
|
+
html << rows.map { |row| row.render(record, options_for_record(record, ix, options)) }.join
|
10
|
+
end
|
11
|
+
end)
|
9
12
|
end
|
10
13
|
|
11
14
|
protected
|
data/lib/simple_table/foot.rb
CHANGED
data/lib/simple_table/head.rb
CHANGED
@@ -3,6 +3,11 @@ module SimpleTable
|
|
3
3
|
self.level = 1
|
4
4
|
self.tag_name = :thead
|
5
5
|
|
6
|
+
def render(*args)
|
7
|
+
build
|
8
|
+
super(rows.map { |row| row.render(*args) })
|
9
|
+
end
|
10
|
+
|
6
11
|
protected
|
7
12
|
|
8
13
|
def build
|
@@ -13,4 +18,4 @@ module SimpleTable
|
|
13
18
|
rows << row
|
14
19
|
end
|
15
20
|
end
|
16
|
-
end
|
21
|
+
end
|
data/lib/simple_table/row.rb
CHANGED
@@ -3,14 +3,13 @@ module SimpleTable
|
|
3
3
|
self.level = 2
|
4
4
|
self.tag_name = :tr
|
5
5
|
|
6
|
-
attr_reader :cells
|
6
|
+
attr_reader :cells, :block
|
7
7
|
|
8
8
|
def initialize(parent, record = nil, options = {}, &block)
|
9
9
|
@parent = parent
|
10
10
|
@options = options
|
11
11
|
@cells = []
|
12
|
-
|
13
|
-
yield(*[self, record].compact) if block_given?
|
12
|
+
@block = block
|
14
13
|
end
|
15
14
|
|
16
15
|
def cell(*contents)
|
@@ -24,12 +23,19 @@ module SimpleTable
|
|
24
23
|
end
|
25
24
|
end
|
26
25
|
|
27
|
-
def render
|
26
|
+
def render(record = nil, options = {})
|
27
|
+
@options.merge!(options)
|
28
|
+
build(record) if block
|
28
29
|
super(cells.map(&:render))
|
29
30
|
end
|
30
31
|
|
31
32
|
protected
|
32
33
|
|
34
|
+
def build(record)
|
35
|
+
@cells = []
|
36
|
+
block.call(*[self, record].compact)
|
37
|
+
end
|
38
|
+
|
33
39
|
def alternate(options)
|
34
40
|
options[:class] ||= ''
|
35
41
|
options[:class] = options[:class].split(' ').push('alternate').join(' ')
|
data/lib/simple_table/rows.rb
CHANGED
data/lib/simple_table/version.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: simple_table
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 63
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 16
|
10
|
+
version: 0.0.16
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Sven Fuchs
|