modular 0.2.2 → 0.2.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -15,10 +15,12 @@ module Modular
15
15
  super(attributes.except("children"))
16
16
  end
17
17
 
18
- def add(type, args = {}, &block)
19
- cont = Modular.create(type, args)
20
- cont.instance_eval &block if block_given?
21
- children.push cont
18
+ def add(type = nil, args = {}, &block)
19
+ unless type.nil?
20
+ cont = Modular.create(type, args)
21
+ cont.instance_eval &block if block_given?
22
+ children.push cont
23
+ end
22
24
  end
23
25
 
24
26
  def valid_with_children?(context = nil)
@@ -1,10 +1,12 @@
1
1
  module Modular
2
+ class Template < ::Mustache
3
+ end
4
+
2
5
  module MstRendering
3
6
  def render
4
- path = Rails.root + "app/views/components/#{type}.mst"
5
- template = File.open(path, "rb").read
6
-
7
- Mustache.render(template, @attributes).html_safe
7
+ Template.template_path = Rails.root + "app/views/components"
8
+ Template.template_extension = 'mst'
9
+ Template.render_file("./#{type}", @attributes).html_safe
8
10
  end
9
11
  end
10
12
  end
@@ -1,3 +1,3 @@
1
1
  module Modular
2
- VERSION = "0.2.2"
2
+ VERSION = "0.2.3"
3
3
  end
@@ -8,6 +8,11 @@ describe Modular::Components::Container, ' vertical container class ' do
8
8
  it "should have children" do
9
9
  @cmp.children.should be_a_kind_of Array
10
10
  end
11
+
12
+ it "should not fail if nil passed to add" do
13
+ @cmp.add nil
14
+ @cmp.children.should be_empty
15
+ end
11
16
 
12
17
  it "should have add_container and add_child methods" do
13
18
  @cmp.add :container, :title => 'Test container title' do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: modular
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.2.3
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: 2012-08-13 00:00:00.000000000 Z
12
+ date: 2012-08-28 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
@@ -151,7 +151,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
151
151
  version: '0'
152
152
  segments:
153
153
  - 0
154
- hash: -3892738958547389268
154
+ hash: 1289225652377390815
155
155
  required_rubygems_version: !ruby/object:Gem::Requirement
156
156
  none: false
157
157
  requirements:
@@ -160,7 +160,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
160
160
  version: '0'
161
161
  segments:
162
162
  - 0
163
- hash: -3892738958547389268
163
+ hash: 1289225652377390815
164
164
  requirements: []
165
165
  rubyforge_project: modular
166
166
  rubygems_version: 1.8.22