express_templates 0.8.0 → 0.9.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5d87ad2dbe75a19f388bac13ec434c7068a49eb6
4
- data.tar.gz: 10a0ef4a3f481e39f1f6420ebd53d41f51fd1ccc
3
+ metadata.gz: 7977047ccc67c08d98fd6455b7cb2489ca8d1443
4
+ data.tar.gz: 9d135566210f9533ec5405070e0fa24f827e77d4
5
5
  SHA512:
6
- metadata.gz: 390bb3ecf10fa33f64988c331b347ef756a6a8e7b2c725ec416200de80982d9e2a2d44bb18110c5983634a792ca6fb98cd7c994842b8951438a71308284237ab
7
- data.tar.gz: b03da196e200da6915bbd3e51b49532003475b8e642f44cd405b7e400f4d60898e132850feb13dcdf3276e98c6d97dceeb894fcc8037635a6dbddec7b425a583
6
+ metadata.gz: 86d2c106761699eeed090914b848e017a1c3f91e5b9de8b5ebd4065f2eec9d966f0e8f3634e69418ff68d670769d5fb1ed9ea6a1842cfd68805c9e622afaf11f
7
+ data.tar.gz: 8a17726987ae8de7ad866e6fc1c5ce4fd1ca0eb5d955442f7eb8139a969931fda38b78f4407912f9c7a2c39cb65c15e37633d6326038f3705f5742e13ae67a60
@@ -5,5 +5,6 @@ end
5
5
 
6
6
  require 'express_templates/components/base'
7
7
  require 'express_templates/components/configurable'
8
+ require 'express_templates/components/container'
8
9
  require 'express_templates/components/tree_for'
9
10
  require 'express_templates/components/forms'
@@ -71,6 +71,10 @@ module ExpressTemplates
71
71
  builder_method_and_class subclass.to_s.demodulize.underscore, subclass
72
72
  end
73
73
 
74
+ def self.descendants
75
+ ObjectSpace.each_object(Class).select { |klass| klass < self }
76
+ end
77
+
74
78
  protected
75
79
  def default_class_name
76
80
  self.class.name.demodulize.underscore.dasherize
@@ -0,0 +1,43 @@
1
+ module ExpressTemplates
2
+ module Components
3
+ class Container < Configurable
4
+
5
+ class_attribute :prepended_blocks
6
+ self.prepended_blocks = []
7
+
8
+ class_attribute :appended_blocks
9
+ self.appended_blocks = []
10
+
11
+ contains -> (&block) {
12
+ prepended
13
+ block.call(self) if block
14
+ appended
15
+ }
16
+
17
+ def prepended
18
+ prepended_blocks.each do |block_to_prepend|
19
+ call_block(block_to_prepend)
20
+ end
21
+ end
22
+
23
+ def appended
24
+ appended_blocks.each do |block_to_append|
25
+ call_block(block_to_append)
26
+ end
27
+ end
28
+
29
+ def call_block(block)
30
+ instance_exec &block
31
+ end
32
+
33
+ def self.prepends(proc = nil, &block)
34
+ self.prepended_blocks += [proc || block]
35
+ end
36
+
37
+ def self.appends(proc = nil, &block)
38
+ self.appended_blocks += [proc || block]
39
+ end
40
+
41
+ end
42
+ end
43
+ end
@@ -1,7 +1,7 @@
1
1
  module ExpressTemplates
2
2
  module Components
3
3
  module Forms
4
- class ExpressForm < Configurable
4
+ class ExpressForm < Container
5
5
  include ExpressTemplates::Components::Capabilities::Resourceful
6
6
 
7
7
  tag :form
@@ -9,13 +9,12 @@ module ExpressTemplates
9
9
  has_option :method, 'The form method', default: 'POST', attribute: true #, options: ['PUT', 'POST', 'GET', 'DELETE']
10
10
  has_option :action, 'The form action containing the resource path or url.'
11
11
 
12
- contains -> (&block) {
12
+ prepends -> {
13
13
  div(style: 'display:none') {
14
14
  add_child helpers.utf8_enforcer_tag
15
15
  add_child helpers.send(:method_tag, resource.persisted? ? :put : :post)
16
16
  helpers.send(:token_tag)
17
17
  }
18
- block.call(self) if block
19
18
  }
20
19
 
21
20
  before_build -> {
@@ -7,10 +7,10 @@ module ExpressTemplates
7
7
 
8
8
  before_build -> {
9
9
  set_attribute(:id, "#{resource_name}_#{field_name}_wrapper")
10
- add_class(config[:class])
10
+ add_class(config[:wrapper_class])
11
11
  }
12
12
 
13
- has_option :class, 'Override the class of the wrapping div of a form component', default: 'field-wrapper', attribute: true
13
+ has_option :wrapper_class, 'Override the class of the wrapping div of a form component', default: 'field-wrapper'
14
14
  has_option :label, 'Override the inferred label of a form component'
15
15
 
16
16
  # Lookup the resource_name from the parent ExpressForm.
@@ -1,3 +1,3 @@
1
1
  module ExpressTemplates
2
- VERSION = "0.8.0"
2
+ VERSION = "0.9.0"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: express_templates
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.0
4
+ version: 0.9.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Steven Talcott Smith
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2015-07-23 00:00:00.000000000 Z
12
+ date: 2015-07-24 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activesupport
@@ -43,16 +43,16 @@ dependencies:
43
43
  name: arbre
44
44
  requirement: !ruby/object:Gem::Requirement
45
45
  requirements:
46
- - - ">="
46
+ - - "~>"
47
47
  - !ruby/object:Gem::Version
48
- version: '0'
48
+ version: '1.0'
49
49
  type: :runtime
50
50
  prerelease: false
51
51
  version_requirements: !ruby/object:Gem::Requirement
52
52
  requirements:
53
- - - ">="
53
+ - - "~>"
54
54
  - !ruby/object:Gem::Version
55
- version: '0'
55
+ version: '1.0'
56
56
  - !ruby/object:Gem::Dependency
57
57
  name: rails
58
58
  requirement: !ruby/object:Gem::Requirement
@@ -151,6 +151,20 @@ dependencies:
151
151
  - - "~>"
152
152
  - !ruby/object:Gem::Version
153
153
  version: '0.4'
154
+ - !ruby/object:Gem::Dependency
155
+ name: minitest-line
156
+ requirement: !ruby/object:Gem::Requirement
157
+ requirements:
158
+ - - ">="
159
+ - !ruby/object:Gem::Version
160
+ version: '0'
161
+ type: :development
162
+ prerelease: false
163
+ version_requirements: !ruby/object:Gem::Requirement
164
+ requirements:
165
+ - - ">="
166
+ - !ruby/object:Gem::Version
167
+ version: '0'
154
168
  description: Replace Erb/HAML/Slim with ExpressTemplates and write templates in a
155
169
  declartive style of Ruby. With ExpressTemplates you may easily create a library
156
170
  of components for use across projects.
@@ -173,6 +187,7 @@ files:
173
187
  - lib/express_templates/components/base.rb
174
188
  - lib/express_templates/components/capabilities/resourceful.rb
175
189
  - lib/express_templates/components/configurable.rb
190
+ - lib/express_templates/components/container.rb
176
191
  - lib/express_templates/components/forms.rb
177
192
  - lib/express_templates/components/forms/basic_fields.rb
178
193
  - lib/express_templates/components/forms/checkbox.rb