mozaic 1.0.0 → 1.1.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
  SHA256:
3
- metadata.gz: 35980466fff36ddb7ab0a0454f497cdde5d9665abfaf2447d427376173134fd2
4
- data.tar.gz: f9260f944122932705d9767deb77119cb92342cc650b23082cbc73eeda26577a
3
+ metadata.gz: b5fedd5a7bc9101ffd3dc4a762f95382080c62725685850e6277b5ea4d4a275c
4
+ data.tar.gz: cbdb9d46a98df57b58c5c65603a769076f1b1a96abcec13785d854f72580ecaa
5
5
  SHA512:
6
- metadata.gz: 273f13503afde1563c9552ea1f0be5b4546f22f89457cc02df25d85a4b578be6e6c651f35074f0689c95230c4faaa5b38cab9312937136202247923dc82bc9f0
7
- data.tar.gz: 337c765c07700f0b43864878bf6d21289373c9e2a16284e59625ee49b432f8c9b652f1f26134edef524cbda8a2ae28d03e0da980c7da2d19612ad03d2c073347
6
+ metadata.gz: 77f210d79c1edee88761405fb708f4634778c115d939d6e7110bb7404d8c25568697bc34f313d09cf2312070686d323fece89f71471eeb17ed328155bf3dd7f3
7
+ data.tar.gz: 7ad2e1b53b406d50d52c66d611e45203c447b49c12d4ca6bea39d3ba895d5d110f806fc9c171d3454a566fbba9e008d5f8eb2a084096b6f74e5168918f583e0c
data/CHANGELOG.md CHANGED
@@ -4,6 +4,11 @@
4
4
 
5
5
  * nothing yet
6
6
 
7
+ ### 1.1.0 - 2018/01/12
8
+
9
+ * features
10
+ * compile and include assets for components
11
+
7
12
  ### 1.0.0 - 2018/01/10
8
13
 
9
14
  * initial release
data/README.md CHANGED
@@ -105,7 +105,7 @@ You can run custom code whenever your component gets rendered:
105
105
 
106
106
  ```ruby
107
107
  Mozaic.configure do |config|
108
- config.define_component :name, lovely: true do
108
+ config.define_component :name, lovely: true do |options|
109
109
  options[:lovely] = !options[:lovely]
110
110
  end
111
111
  end
@@ -145,6 +145,23 @@ Here is how to access a block in your component:
145
145
  = block
146
146
  ```
147
147
 
148
+ ### Assets
149
+
150
+ With Mozaic you can automatically add assets to the asset pipeline just by naming the like the component they belong to. Just require Mozaic in your application assets:
151
+
152
+ ```javascript
153
+ //= require_tree ./mozaic
154
+ ```
155
+ ```css
156
+ /*
157
+ *= require_tree ./mozaic
158
+ */
159
+ ```
160
+
161
+ For instance a component with the name `'my/test/component'` can have a javascript asset located at `app/assets/javascripts/mozaic/my/test/component.js` and a stylesheet under `app/assets/stylesheets/mozaic/my/test/component.css`.
162
+
163
+ **Note:** Asset files are being created automatically when using the component generator.
164
+
148
165
  ---
149
166
 
150
167
  ## Configuration
@@ -8,7 +8,7 @@ module Mozaic
8
8
  end
9
9
 
10
10
  def component_wrapper name, options = {}, &block
11
- content_tag class: "#{name.to_s.split('/').join(' ')} #{options[:class]}", id: options[:id] do
11
+ content_tag class: "mozaic--component #{name.to_s.split('/').join(' ')} #{options[:class]}", id: options[:id] do
12
12
  capture(&block)
13
13
  end
14
14
  end
@@ -15,6 +15,8 @@ module Mozaic
15
15
  names = options[:name].split('/')
16
16
  name = names.pop
17
17
  template 'partial.html.erb', "app/views/mozaic/#{names.join('/')}/_#{name}.html.erb"
18
+ template 'asset.js.erb', "app/assets/javascripts/mozaic/#{options[:name]}.js"
19
+ template 'asset.css.erb', "app/assets/stylesheets/mozaic/#{options[:name]}.css"
18
20
  end
19
21
 
20
22
  end
@@ -17,5 +17,10 @@ module Mozaic
17
17
  template 'layout.html.erb', 'app/views/layouts/mozaic.html.erb'
18
18
  end
19
19
 
20
+ def create_assets
21
+ template '.keep', 'app/assets/javascripts/mozaic/.keep'
22
+ template '.keep', 'app/assets/stylesheets/mozaic/.keep'
23
+ end
24
+
20
25
  end
21
26
  end
@@ -0,0 +1,2 @@
1
+ .mozaic--component.<%= options[:name].split('/').join('.') %>
2
+ /* ... */
@@ -0,0 +1,11 @@
1
+ $(document).on( 'turbolinks:load', function() {
2
+ if ( $('.mozaic--component.<%= options[:name].split("/").join(".") %>').length > 0 ) {
3
+ <%= options[:name].split("/").each_with_index.map { |s, i| i == 0 ? s : s.capitalize }.join('') %>Init();
4
+ };
5
+ });
6
+
7
+
8
+
9
+ function <%= options[:name].split("/").each_with_index.map { |s, i| i == 0 ? s : s.capitalize }.join('') %>Init() {
10
+ // ...
11
+ };
@@ -20,7 +20,7 @@ module Mozaic
20
20
 
21
21
  def render options = {}
22
22
  self.options = self.options options
23
- self.block.call unless self.block.nil?
23
+ self.block.call(self.options) unless self.block.nil?
24
24
  end
25
25
 
26
26
  def self.find_by_name name
@@ -1,5 +1,5 @@
1
1
  module Mozaic
2
2
 
3
- VERSION = '1.0.0'
3
+ VERSION = '1.1.0'
4
4
 
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mozaic
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jonas Hübotter
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-01-10 00:00:00.000000000 Z
11
+ date: 2018-01-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: railties
@@ -95,6 +95,8 @@ files:
95
95
  - lib/generators/mozaic/component_generator.rb
96
96
  - lib/generators/mozaic/install_generator.rb
97
97
  - lib/generators/mozaic/layout_generator.rb
98
+ - lib/generators/templates/component/asset.css.erb
99
+ - lib/generators/templates/component/asset.js.erb
98
100
  - lib/generators/templates/component/partial.html.erb
99
101
  - lib/generators/templates/install/initializer.rb
100
102
  - lib/generators/templates/install/layout.html.erb