modular 0.1.2 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +2 -0
- data/.rvmrc +1 -0
- data/.travis.yml +2 -0
- data/Gemfile +14 -0
- data/Gemfile.lock +155 -0
- data/LICENSE +7 -0
- data/README.rdoc +21 -0
- data/Rakefile +14 -2
- data/TODO +3 -2
- data/config.ru +7 -0
- data/lib/modular.rb +15 -35
- data/lib/modular/action_controller_extension.rb +20 -0
- data/lib/modular/components.rb +6 -0
- data/lib/modular/components/base.rb +9 -7
- data/lib/modular/components/container.rb +1 -10
- data/lib/modular/components/main_content.rb +1 -3
- data/lib/modular/configuration.rb +10 -10
- data/lib/modular/creation.rb +29 -0
- data/lib/modular/{abstract_model.rb → helpers.rb} +0 -0
- data/lib/modular/layout_generator.rb +8 -7
- data/lib/modular/railtie.rb +11 -0
- data/lib/modular/rendering.rb +68 -73
- data/lib/modular/version.rb +1 -1
- data/modular.gemspec +0 -1
- data/{modular-app/spec → spec}/components/base.rb +0 -0
- data/{modular-app/spec → spec}/components/container.rb +3 -3
- data/{modular-app/spec → spec}/components/hello_world.rb +0 -0
- data/{modular-app/spec → spec}/components/helpers_example.rb +0 -0
- data/{modular-app/spec → spec}/components/validated.rb +0 -0
- data/{modular-app/spec → spec}/controllers/cached_for_time_controller_spec.rb +0 -0
- data/{modular-app/spec → spec}/controllers/cached_forever_controller_spec.rb +0 -0
- data/{modular-app/spec → spec}/controllers/callback_layout_controller_spec.rb +0 -0
- data/{modular-app/spec → spec}/controllers/example_controller_spec.rb +0 -0
- data/{modular-app/spec → spec}/controllers/indirect_render_controller_spec.rb +0 -0
- data/{modular-app/spec → spec}/controllers/layout_test_controller_spec.rb +1 -1
- data/{modular-app → spec/internal}/app/components/cached_for_time.rb +2 -4
- data/spec/internal/app/components/cached_forever.rb +8 -0
- data/spec/internal/app/components/fake_news_feed.rb +3 -0
- data/{modular-app → spec/internal}/app/components/foobar.rb +0 -0
- data/spec/internal/app/components/heavy_task.rb +8 -0
- data/{modular-app → spec/internal}/app/components/hello_world.rb +0 -0
- data/{modular-app → spec/internal}/app/components/helpers_example.rb +0 -0
- data/{modular-app → spec/internal}/app/components/validated.rb +0 -0
- data/{modular-app → spec/internal}/app/components/vertical.rb +0 -0
- data/{modular-app → spec/internal}/app/controllers/application_controller.rb +0 -0
- data/{modular-app → spec/internal}/app/controllers/cached_for_time_controller.rb +0 -0
- data/{modular-app → spec/internal}/app/controllers/cached_forever_controller.rb +0 -0
- data/{modular-app → spec/internal}/app/controllers/callback_layout_controller.rb +0 -0
- data/{modular-app → spec/internal}/app/controllers/example_controller.rb +0 -0
- data/{modular-app → spec/internal}/app/controllers/indirect_render_controller.rb +0 -0
- data/{modular-app → spec/internal}/app/controllers/layout_test_controller.rb +0 -0
- data/{modular-app → spec/internal}/app/models/simple_model.rb +0 -0
- data/{modular-app → spec/internal}/app/views/cached_for_time/index.html.erb +0 -0
- data/{modular-app → spec/internal}/app/views/cached_forever/index.html.erb +0 -0
- data/{modular-app → spec/internal}/app/views/callback_layout/index.html.erb +0 -0
- data/{modular-app → spec/internal}/app/views/components/cached_for_time.html.erb +0 -0
- data/{modular-app → spec/internal}/app/views/components/cached_forever.html.erb +0 -0
- data/{modular-app → spec/internal}/app/views/components/container.html.erb +0 -0
- data/{modular-app → spec/internal}/app/views/components/fake_news_feed.html.erb +0 -0
- data/{modular-app → spec/internal}/app/views/components/foobar.html.erb +0 -0
- data/{modular-app → spec/internal}/app/views/components/heavy_task.html.erb +0 -0
- data/{modular-app → spec/internal}/app/views/components/hello_world.html.erb +0 -0
- data/{modular-app → spec/internal}/app/views/components/helpers_example.html.erb +0 -0
- data/{modular-app → spec/internal}/app/views/components/validated.html.erb +0 -0
- data/{modular-app → spec/internal}/app/views/components/vertical.html.erb +0 -0
- data/{modular-app → spec/internal}/app/views/example/index.html.erb +0 -0
- data/{modular-app → spec/internal}/app/views/indirect_render/index.html.erb +0 -0
- data/{modular-app → spec/internal}/app/views/layout_test/index.html.erb +0 -0
- data/{modular-app → spec/internal}/app/views/layouts/application.html.erb +0 -0
- data/spec/internal/config/database.yml +3 -0
- data/{modular-app → spec/internal}/config/initializers/modular.rb +1 -1
- data/spec/internal/config/routes.rb +7 -0
- data/spec/internal/db/schema.rb +6 -0
- data/spec/internal/log/.gitignore +1 -0
- data/{README → spec/internal/public/favicon.ico} +0 -0
- data/spec/internal/tmp/.gitkeep +0 -0
- data/spec/internal/tmp/modular/cached_for_time.html.erb +14 -0
- data/spec/internal/tmp/modular/cached_forever.html.erb +12 -0
- data/spec/internal/tmp/modular/heavy.html.erb +19 -0
- data/spec/internal/tmp/modular/nested.html.erb +28 -0
- data/spec/modular/configuration_spec.rb +46 -0
- data/spec/{base.rb → modular/creation_spec.rb} +11 -16
- data/spec/spec_helper.rb +11 -3
- data/spec/views/indirect_render/index.html.erb_spec.rb +4 -0
- data/templates/layout.erb +5 -10
- metadata +119 -133
- data/autotest/discover.rb +0 -12
- data/lib/modular/rails.rb +0 -16
- data/modular-app/app/components/cached_forever.rb +0 -10
- data/modular-app/app/components/fake_news_feed.rb +0 -9
- data/modular-app/app/components/heavy_task.rb +0 -5
- data/modular-app/app/helpers/application_helper.rb +0 -2
- data/modular-app/app/helpers/callback_layout_helper.rb +0 -2
- data/modular-app/app/helpers/example_helper.rb +0 -2
- data/modular-app/app/helpers/indirect_render_helper.rb +0 -2
- data/modular-app/spec/helpers/indirect_render_helper_spec.rb +0 -14
- data/modular-app/spec/views/indirect_render/index.html.erb_spec.rb +0 -4
- data/spec/configuration.rb +0 -74
data/.gitignore
ADDED
data/.rvmrc
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
rvm use 1.9.3-falcon
|
data/.travis.yml
ADDED
data/Gemfile
CHANGED
@@ -2,3 +2,17 @@ source "http://rubygems.org"
|
|
2
2
|
|
3
3
|
# Specify your gem's dependencies in modular.gemspec
|
4
4
|
gemspec
|
5
|
+
|
6
|
+
gem 'rails', '~> 3.2.0'
|
7
|
+
|
8
|
+
gem 'rspec-rails', :require => false
|
9
|
+
gem 'rspec'
|
10
|
+
gem 'capybara'
|
11
|
+
gem "combustion", "~> 0.3.2"
|
12
|
+
gem 'sqlite3'
|
13
|
+
|
14
|
+
gem 'memcache-client'
|
15
|
+
|
16
|
+
gem 'pry'
|
17
|
+
gem 'pry-nav'
|
18
|
+
gem 'webrat'
|
data/Gemfile.lock
ADDED
@@ -0,0 +1,155 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
modular (0.2.0)
|
5
|
+
rails
|
6
|
+
|
7
|
+
GEM
|
8
|
+
remote: http://rubygems.org/
|
9
|
+
specs:
|
10
|
+
actionmailer (3.2.6)
|
11
|
+
actionpack (= 3.2.6)
|
12
|
+
mail (~> 2.4.4)
|
13
|
+
actionpack (3.2.6)
|
14
|
+
activemodel (= 3.2.6)
|
15
|
+
activesupport (= 3.2.6)
|
16
|
+
builder (~> 3.0.0)
|
17
|
+
erubis (~> 2.7.0)
|
18
|
+
journey (~> 1.0.1)
|
19
|
+
rack (~> 1.4.0)
|
20
|
+
rack-cache (~> 1.2)
|
21
|
+
rack-test (~> 0.6.1)
|
22
|
+
sprockets (~> 2.1.3)
|
23
|
+
activemodel (3.2.6)
|
24
|
+
activesupport (= 3.2.6)
|
25
|
+
builder (~> 3.0.0)
|
26
|
+
activerecord (3.2.6)
|
27
|
+
activemodel (= 3.2.6)
|
28
|
+
activesupport (= 3.2.6)
|
29
|
+
arel (~> 3.0.2)
|
30
|
+
tzinfo (~> 0.3.29)
|
31
|
+
activeresource (3.2.6)
|
32
|
+
activemodel (= 3.2.6)
|
33
|
+
activesupport (= 3.2.6)
|
34
|
+
activesupport (3.2.6)
|
35
|
+
i18n (~> 0.6)
|
36
|
+
multi_json (~> 1.0)
|
37
|
+
addressable (2.2.8)
|
38
|
+
arel (3.0.2)
|
39
|
+
builder (3.0.0)
|
40
|
+
capybara (1.1.2)
|
41
|
+
mime-types (>= 1.16)
|
42
|
+
nokogiri (>= 1.3.3)
|
43
|
+
rack (>= 1.0.0)
|
44
|
+
rack-test (>= 0.5.4)
|
45
|
+
selenium-webdriver (~> 2.0)
|
46
|
+
xpath (~> 0.1.4)
|
47
|
+
childprocess (0.3.3)
|
48
|
+
ffi (~> 1.0.6)
|
49
|
+
coderay (1.0.7)
|
50
|
+
combustion (0.3.2)
|
51
|
+
rails (>= 3.0.0)
|
52
|
+
thor (>= 0.14.6)
|
53
|
+
diff-lcs (1.1.3)
|
54
|
+
erubis (2.7.0)
|
55
|
+
ffi (1.0.11)
|
56
|
+
hike (1.2.1)
|
57
|
+
i18n (0.6.0)
|
58
|
+
journey (1.0.4)
|
59
|
+
json (1.7.3)
|
60
|
+
libwebsocket (0.1.3)
|
61
|
+
addressable
|
62
|
+
mail (2.4.4)
|
63
|
+
i18n (>= 0.4.0)
|
64
|
+
mime-types (~> 1.16)
|
65
|
+
treetop (~> 1.4.8)
|
66
|
+
memcache-client (1.8.5)
|
67
|
+
method_source (0.7.1)
|
68
|
+
mime-types (1.19)
|
69
|
+
multi_json (1.3.6)
|
70
|
+
nokogiri (1.5.5)
|
71
|
+
polyglot (0.3.3)
|
72
|
+
pry (0.9.9.6)
|
73
|
+
coderay (~> 1.0.5)
|
74
|
+
method_source (~> 0.7.1)
|
75
|
+
slop (>= 2.4.4, < 3)
|
76
|
+
pry-nav (0.2.1)
|
77
|
+
pry (~> 0.9.9)
|
78
|
+
rack (1.4.1)
|
79
|
+
rack-cache (1.2)
|
80
|
+
rack (>= 0.4)
|
81
|
+
rack-ssl (1.3.2)
|
82
|
+
rack
|
83
|
+
rack-test (0.6.1)
|
84
|
+
rack (>= 1.0)
|
85
|
+
rails (3.2.6)
|
86
|
+
actionmailer (= 3.2.6)
|
87
|
+
actionpack (= 3.2.6)
|
88
|
+
activerecord (= 3.2.6)
|
89
|
+
activeresource (= 3.2.6)
|
90
|
+
activesupport (= 3.2.6)
|
91
|
+
bundler (~> 1.0)
|
92
|
+
railties (= 3.2.6)
|
93
|
+
railties (3.2.6)
|
94
|
+
actionpack (= 3.2.6)
|
95
|
+
activesupport (= 3.2.6)
|
96
|
+
rack-ssl (~> 1.3.2)
|
97
|
+
rake (>= 0.8.7)
|
98
|
+
rdoc (~> 3.4)
|
99
|
+
thor (>= 0.14.6, < 2.0)
|
100
|
+
rake (0.9.2.2)
|
101
|
+
rdoc (3.12)
|
102
|
+
json (~> 1.4)
|
103
|
+
rspec (2.11.0)
|
104
|
+
rspec-core (~> 2.11.0)
|
105
|
+
rspec-expectations (~> 2.11.0)
|
106
|
+
rspec-mocks (~> 2.11.0)
|
107
|
+
rspec-core (2.11.0)
|
108
|
+
rspec-expectations (2.11.1)
|
109
|
+
diff-lcs (~> 1.1.3)
|
110
|
+
rspec-mocks (2.11.1)
|
111
|
+
rspec-rails (2.11.0)
|
112
|
+
actionpack (>= 3.0)
|
113
|
+
activesupport (>= 3.0)
|
114
|
+
railties (>= 3.0)
|
115
|
+
rspec (~> 2.11.0)
|
116
|
+
rubyzip (0.9.9)
|
117
|
+
selenium-webdriver (2.24.0)
|
118
|
+
childprocess (>= 0.2.5)
|
119
|
+
libwebsocket (~> 0.1.3)
|
120
|
+
multi_json (~> 1.0)
|
121
|
+
rubyzip
|
122
|
+
slop (2.4.4)
|
123
|
+
sprockets (2.1.3)
|
124
|
+
hike (~> 1.2)
|
125
|
+
rack (~> 1.0)
|
126
|
+
tilt (~> 1.1, != 1.3.0)
|
127
|
+
sqlite3 (1.3.6)
|
128
|
+
thor (0.15.4)
|
129
|
+
tilt (1.3.3)
|
130
|
+
treetop (1.4.10)
|
131
|
+
polyglot
|
132
|
+
polyglot (>= 0.3.1)
|
133
|
+
tzinfo (0.3.33)
|
134
|
+
webrat (0.7.3)
|
135
|
+
nokogiri (>= 1.2.0)
|
136
|
+
rack (>= 1.0)
|
137
|
+
rack-test (>= 0.5.3)
|
138
|
+
xpath (0.1.4)
|
139
|
+
nokogiri (~> 1.3)
|
140
|
+
|
141
|
+
PLATFORMS
|
142
|
+
ruby
|
143
|
+
|
144
|
+
DEPENDENCIES
|
145
|
+
capybara
|
146
|
+
combustion (~> 0.3.2)
|
147
|
+
memcache-client
|
148
|
+
modular!
|
149
|
+
pry
|
150
|
+
pry-nav
|
151
|
+
rails (~> 3.2.0)
|
152
|
+
rspec
|
153
|
+
rspec-rails
|
154
|
+
sqlite3
|
155
|
+
webrat
|
data/LICENSE
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
Copyright (C) 2011-2012, Alex Rozumiy
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
4
|
+
|
5
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
6
|
+
|
7
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
= Modular
|
2
|
+
|
3
|
+
This gem makes changing layout structure as easy as change ruby hash structure.
|
4
|
+
|
5
|
+
= Build Status {<img src="https://secure.travis-ci.org/brain-geek/modular.png"/>}[http://travis-ci.org/brain-geek/modular]
|
6
|
+
|
7
|
+
= How to use
|
8
|
+
See example in spec/internal.
|
9
|
+
|
10
|
+
== Contributing to modular
|
11
|
+
|
12
|
+
* Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
|
13
|
+
* Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
|
14
|
+
* Fork the project.
|
15
|
+
* Commit and push until you are happy with your contribution.
|
16
|
+
* Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
|
17
|
+
* Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
|
18
|
+
|
19
|
+
== Copyright
|
20
|
+
|
21
|
+
Copyright (c) 2011-2012 Alex Rozumey. See LICENSE for further details.
|
data/Rakefile
CHANGED
@@ -1,2 +1,14 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
begin
|
4
|
+
require 'bundler'
|
5
|
+
Bundler::GemHelper.install_tasks
|
6
|
+
rescue LoadError => e
|
7
|
+
warn "[WARNING]: It is recommended that you use bundler during development: gem install bundler"
|
8
|
+
end
|
9
|
+
|
10
|
+
require 'rspec/core/rake_task'
|
11
|
+
|
12
|
+
RSpec::Core::RakeTask.new('spec')
|
13
|
+
|
14
|
+
task :default => :spec
|
data/TODO
CHANGED
@@ -1,2 +1,3 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
*** Allow accessing request object from components
|
2
|
+
** Write README with usage examples
|
3
|
+
* Clean up obsolete classes/components in app
|
data/config.ru
ADDED
data/lib/modular.rb
CHANGED
@@ -1,45 +1,29 @@
|
|
1
|
-
require
|
1
|
+
require 'rails'
|
2
|
+
require 'modular/railtie'
|
2
3
|
|
3
4
|
module Modular
|
4
5
|
extend ActiveSupport::Autoload
|
5
6
|
|
6
7
|
eager_autoload do
|
8
|
+
autoload :Creation
|
7
9
|
autoload :Configuration
|
8
10
|
autoload :LayoutGenerator
|
11
|
+
autoload :Helpers
|
9
12
|
end
|
10
|
-
|
11
|
-
|
12
|
-
return typ if typ.is_a? Components::Base
|
13
|
-
|
14
|
-
begin
|
15
|
-
begin
|
16
|
-
component = typ.to_s.camelize.constantize.new params
|
17
|
-
rescue NameError
|
18
|
-
component = (Components.name + '::' + typ.to_s.camelize).constantize.new params
|
19
|
-
end
|
20
|
-
rescue Exception => e
|
21
|
-
raise "Unable to create element " + typ.to_s
|
22
|
-
end
|
23
|
-
|
24
|
-
raise "Component has errors: " + component.errors.to_s unless component.valid?
|
25
|
-
|
26
|
-
component
|
27
|
-
end
|
28
|
-
|
29
|
-
def from_json(text)
|
30
|
-
obj = ActiveSupport::JSON.decode text
|
31
|
-
raise "Type expected in json string" unless obj['type']
|
32
|
-
create(obj['type'], obj.except('type'))
|
33
|
-
end
|
34
|
-
|
13
|
+
|
14
|
+
delegate :create, :from_json, :to => Creation
|
35
15
|
delegate :config, :configure, :to => Configuration
|
36
16
|
|
37
17
|
def layout(id)
|
38
|
-
Configuration.config.layouts
|
18
|
+
if Configuration.config.layouts.has_key?(id)
|
19
|
+
Configuration.config.layouts[id]
|
20
|
+
else
|
21
|
+
raise "Layout '#{id}' not found"
|
22
|
+
end
|
39
23
|
end
|
40
|
-
|
24
|
+
|
41
25
|
def layouts
|
42
|
-
Configuration.config.layouts
|
26
|
+
Configuration.config.layouts
|
43
27
|
end
|
44
28
|
|
45
29
|
def generate_rails_layout(id, params = {})
|
@@ -49,9 +33,5 @@ module Modular
|
|
49
33
|
extend self
|
50
34
|
end
|
51
35
|
|
52
|
-
require "modular/components
|
53
|
-
require "modular/
|
54
|
-
require "modular/components/main_content"
|
55
|
-
require "modular/version"
|
56
|
-
|
57
|
-
require "modular/rails" if defined? Rails
|
36
|
+
require "modular/components"
|
37
|
+
require "modular/version"
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module Modular::ActionControllerExtension
|
2
|
+
extend ActiveSupport::Concern
|
3
|
+
|
4
|
+
def render_modular_layout(name)
|
5
|
+
layout = Modular.layout name
|
6
|
+
render :text => layout.render
|
7
|
+
end
|
8
|
+
|
9
|
+
module ClassMethods
|
10
|
+
def modular_layout(name, params = {})
|
11
|
+
proc = Proc.new do |controller|
|
12
|
+
path = '../../../' + Modular.generate_rails_layout(name.is_a?(Symbol) ? controller.__send__(name) : name, params)
|
13
|
+
#cutting off '.html.erb'
|
14
|
+
path[0, path.length-9]
|
15
|
+
end
|
16
|
+
|
17
|
+
layout proc
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -1,5 +1,4 @@
|
|
1
1
|
require 'abstract_controller'
|
2
|
-
require "modular/abstract_model"
|
3
2
|
require "modular/rendering"
|
4
3
|
require "modular/caching"
|
5
4
|
|
@@ -7,9 +6,13 @@ module Modular
|
|
7
6
|
module Components
|
8
7
|
class Base < Modular::Helpers::AbstractModel
|
9
8
|
#rendering
|
10
|
-
include AbstractController
|
11
|
-
include
|
12
|
-
include Modular::
|
9
|
+
include AbstractController::Rendering
|
10
|
+
include AbstractController::Helpers
|
11
|
+
include Modular::Rendering
|
12
|
+
|
13
|
+
def self.abstract?
|
14
|
+
true
|
15
|
+
end
|
13
16
|
|
14
17
|
#slug
|
15
18
|
def self.type
|
@@ -21,10 +24,9 @@ module Modular
|
|
21
24
|
end
|
22
25
|
|
23
26
|
#params for element itself
|
24
|
-
|
25
|
-
attr_reader :title
|
27
|
+
attr_accessor :title
|
26
28
|
|
27
|
-
validates :title, :length => {:maximum => 64}
|
29
|
+
validates :title, :length => {:maximum => 64}
|
28
30
|
end
|
29
31
|
end
|
30
32
|
end
|
@@ -1,8 +1,6 @@
|
|
1
1
|
module Modular
|
2
2
|
module Components
|
3
3
|
class Container < Base
|
4
|
-
include Modular::Components::IndirectRender
|
5
|
-
|
6
4
|
attr_accessor :components
|
7
5
|
|
8
6
|
def initialize(attributes = {})
|
@@ -26,14 +24,7 @@ module Modular
|
|
26
24
|
cont.instance_eval &block if block_given?
|
27
25
|
components.push cont
|
28
26
|
end
|
29
|
-
|
30
|
-
# def render_child(component, render_type)
|
31
|
-
# if component.is_a?(Modular::Components::IndirectRender)&&(render_type == :indirect)
|
32
|
-
# component.indirect_render.html_safe
|
33
|
-
# else
|
34
|
-
# ("<%= Modular.from_json('" + component.to_json.html_safe + "').render %>").html_safe
|
35
|
-
# end
|
36
|
-
# end
|
27
|
+
|
37
28
|
end
|
38
29
|
end
|
39
30
|
end
|
@@ -1,22 +1,23 @@
|
|
1
|
+
require 'singleton'
|
2
|
+
|
1
3
|
module Modular
|
2
4
|
class Configuration
|
3
|
-
|
4
|
-
|
5
|
-
attr_accessor_with_default :padding_width, 15
|
5
|
+
include ::Singleton
|
6
|
+
|
6
7
|
attr_reader :layouts
|
7
8
|
|
8
9
|
def self.config
|
9
|
-
|
10
|
+
self.instance
|
10
11
|
end
|
11
12
|
|
12
13
|
def self.configure(&block)
|
13
|
-
|
14
|
-
|
15
|
-
|
14
|
+
instance = self.instance
|
15
|
+
instance.instance_eval &block if block_given?
|
16
|
+
instance
|
16
17
|
end
|
17
18
|
|
18
|
-
def register_layout(layout, mod = :
|
19
|
-
@layouts ||=
|
19
|
+
def register_layout(layout, mod = :container, params = {}, &block)
|
20
|
+
@layouts ||= Hash.new.with_indifferent_access
|
20
21
|
|
21
22
|
if mod.is_a? Components::Base
|
22
23
|
@layouts[layout.to_s] = mod
|
@@ -26,6 +27,5 @@ module Modular
|
|
26
27
|
@layouts[layout.to_s] = root_layout
|
27
28
|
end
|
28
29
|
end
|
29
|
-
|
30
30
|
end
|
31
31
|
end
|