toolsmith 0.0.12 → 0.0.13
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.
- data/CHANGELOG.md +5 -0
- data/lib/toolsmith.rb +1 -0
- data/lib/toolsmith/helpers/definition_list_for_helpers.rb +12 -0
- data/lib/toolsmith/version.rb +1 -1
- data/lib/toolsmith/view_helpers.rb +2 -0
- data/lib/toolsmith/views/definition_list.rb +5 -3
- data/lib/toolsmith/views/definition_list_for.rb +39 -0
- metadata +4 -2
data/CHANGELOG.md
CHANGED
data/lib/toolsmith.rb
CHANGED
@@ -11,6 +11,7 @@ module Toolsmith
|
|
11
11
|
autoload :PageHeader, "toolsmith/views/page_header"
|
12
12
|
autoload :FlashDiv, "toolsmith/views/flash_div"
|
13
13
|
autoload :DefinitionList, "toolsmith/views/definition_list"
|
14
|
+
autoload :DefinitionListFor, "toolsmith/views/definition_list_for"
|
14
15
|
end
|
15
16
|
|
16
17
|
MissingParameter = Class.new(StandardError)
|
@@ -0,0 +1,12 @@
|
|
1
|
+
module Toolsmith
|
2
|
+
module ViewHelpers
|
3
|
+
module DefinitionListForHelpers
|
4
|
+
def definition_list_for(object, options={}, &block)
|
5
|
+
definition_list = Toolsmith::Views::DefinitionListFor.new_with_object(self, object, &block)
|
6
|
+
definition_list.options.merge!(options)
|
7
|
+
yield definition_list
|
8
|
+
definition_list
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
data/lib/toolsmith/version.rb
CHANGED
@@ -2,6 +2,7 @@ require "toolsmith/helpers/bootstrap_helpers"
|
|
2
2
|
require "toolsmith/helpers/grid_helpers"
|
3
3
|
require "toolsmith/helpers/page_header_helpers"
|
4
4
|
require "toolsmith/helpers/definition_list_helpers"
|
5
|
+
require "toolsmith/helpers/definition_list_for_helpers"
|
5
6
|
|
6
7
|
module Toolsmith
|
7
8
|
module ViewHelpers
|
@@ -9,5 +10,6 @@ module Toolsmith
|
|
9
10
|
include GridHelpers
|
10
11
|
include PageHeaderHelpers
|
11
12
|
include DefinitionListHelpers
|
13
|
+
include DefinitionListForHelpers
|
12
14
|
end
|
13
15
|
end
|
@@ -1,13 +1,13 @@
|
|
1
1
|
module Toolsmith
|
2
2
|
module Views
|
3
3
|
class DefinitionList < Base
|
4
|
-
|
4
|
+
DEFAULT_OPTIONS = { horizontal: true }
|
5
5
|
|
6
6
|
attr_reader :content_block, :options
|
7
7
|
|
8
8
|
def initialize(context, options={}, &block)
|
9
9
|
@content_block = block if block_given?
|
10
|
-
@options = options
|
10
|
+
@options = DEFAULT_OPTIONS.merge(options)
|
11
11
|
super(context, &nil)
|
12
12
|
end
|
13
13
|
|
@@ -24,7 +24,9 @@ module Toolsmith
|
|
24
24
|
private
|
25
25
|
|
26
26
|
def dl_options
|
27
|
-
{
|
27
|
+
{
|
28
|
+
class: options[:horizontal] ? "dl-horizontal" : nil
|
29
|
+
}
|
28
30
|
end
|
29
31
|
end
|
30
32
|
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
module Toolsmith
|
2
|
+
module Views
|
3
|
+
class DefinitionListFor < Base
|
4
|
+
attr_accessor :object, :options
|
5
|
+
attr_reader :content_block
|
6
|
+
|
7
|
+
DEFAULT_OPTIONS = { horizontal: true }
|
8
|
+
|
9
|
+
def initialize(context, &block)
|
10
|
+
@content_block = block if block_given?
|
11
|
+
@options = DEFAULT_OPTIONS.dup
|
12
|
+
super(context, &nil)
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.new_with_object(context, object, &block)
|
16
|
+
definition_list = new(context, &block)
|
17
|
+
definition_list.object = object
|
18
|
+
definition_list
|
19
|
+
end
|
20
|
+
|
21
|
+
def define(attribute)
|
22
|
+
human_attribute = attribute.to_s.humanize
|
23
|
+
|
24
|
+
content_tag(:dt, human_attribute) + content_tag(:dd, object.send(attribute))
|
25
|
+
end
|
26
|
+
|
27
|
+
def to_s
|
28
|
+
content = context.capture(self, &content_block)
|
29
|
+
content_tag :dl, content, dl_options
|
30
|
+
end
|
31
|
+
|
32
|
+
def dl_options
|
33
|
+
{
|
34
|
+
class: options[:horizontal] ? "dl-horizontal" : nil
|
35
|
+
}
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: toolsmith
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.13
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2013-
|
13
|
+
date: 2013-03-01 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rails
|
@@ -162,6 +162,7 @@ files:
|
|
162
162
|
- lib/toolsmith/core_ext/array.rb
|
163
163
|
- lib/toolsmith/engine.rb
|
164
164
|
- lib/toolsmith/helpers/bootstrap_helpers.rb
|
165
|
+
- lib/toolsmith/helpers/definition_list_for_helpers.rb
|
165
166
|
- lib/toolsmith/helpers/definition_list_helpers.rb
|
166
167
|
- lib/toolsmith/helpers/grid_helpers.rb
|
167
168
|
- lib/toolsmith/helpers/page_header_helpers.rb
|
@@ -169,6 +170,7 @@ files:
|
|
169
170
|
- lib/toolsmith/view_helpers.rb
|
170
171
|
- lib/toolsmith/views/base.rb
|
171
172
|
- lib/toolsmith/views/definition_list.rb
|
173
|
+
- lib/toolsmith/views/definition_list_for.rb
|
172
174
|
- lib/toolsmith/views/flash_div.rb
|
173
175
|
- lib/toolsmith/views/page_header.rb
|
174
176
|
- lib/toolsmith.rb
|