futurism 0.3.1 → 0.3.2

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: d4790301758ddfdcf0a2e22b4f0f55977cdaf96f64fcef74ba85ccb4f6e7c71c
4
- data.tar.gz: 07435fbcfbc75b1846015b319f8dc2056897f8cbb020ff29bf92c48366ea8a9a
3
+ metadata.gz: c5a13955e5c2902320a9eb601cd12058c16782a4002ec2c05ca1dff9eddd3190
4
+ data.tar.gz: 636b6c0b298bb686600026d5f065190e2c94edec85a25c0afa715891841c0b38
5
5
  SHA512:
6
- metadata.gz: 88a0bb998ccc4192238f8936f80f77cf9b938bd70d141413be1d049265e59eb555d35ad77940ebae8d072b512aa97291a81d57ac1d397bf9c8fc37d54db4e55a
7
- data.tar.gz: 6d5e8a2af44e58857f27fb54e6304f903c43901a05e8036f0ba1622e8ed0b8c29fbdbf1fc99e2fdfcbcaf841430ed3f3a7e5bd7d905d891797bbf294d803fe8b
6
+ metadata.gz: ee386095ed1c02325e6eea34b0f8a85e67709a0a4b17d5705de035cf7bac667487687a99135654f15bc24f202b81af9d6320d70b61c296279e6c8bc437fc9d96
7
+ data.tar.gz: 8e73598941f69c36aac9e2b53536369e1cb689a50e76986692c37cc04fca2d253abe7dfb7b3416fa657f0bdbc29f7d34aac4920ec5b9ecff3ce44f4368e672c6
data/README.md CHANGED
@@ -1,7 +1,7 @@
1
1
  # Futurism
2
2
  [![Twitter follow](https://img.shields.io/twitter/follow/julian_rubisch?style=social)](https://twitter.com/julian_rubisch)
3
3
  <!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->
4
- [![All Contributors](https://img.shields.io/badge/all_contributors-8-orange.svg?style=flat-square)](#contributors-)
4
+ [![All Contributors](https://img.shields.io/badge/all_contributors-10-orange.svg?style=flat-square)](#contributors-)
5
5
  <!-- ALL-CONTRIBUTORS-BADGE:END -->
6
6
  Lazy-load Rails partials via CableReady
7
7
 
@@ -93,6 +93,16 @@ You can also use the shorthand syntax:
93
93
  <% end %>
94
94
  ```
95
95
 
96
+ #### Collections
97
+
98
+ Collection rendering is also possible:
99
+
100
+ ```erb
101
+ <%= futurize partial: "items/card", collection: @cards, extends: :div do %>
102
+ <div class="spinner"></div>
103
+ <% end %>
104
+ ```
105
+
96
106
  ### HTML Options
97
107
 
98
108
  You can pass a hash of attribute/value pairs which will be mixed into the HTML markup for the placeholder element. This is important for layouts that require elements to have dimensionality. For example, many scripts calculate size based on element height and width. This option ensures that your elements have integrity, even if they are gone before you see them.
@@ -111,16 +121,6 @@ This will output the following:
111
121
  </tr>
112
122
  ```
113
123
 
114
- #### Collections
115
-
116
- Collection rendering is also possible:
117
-
118
- ```erb
119
- <%= futurize partial: "items/card", collection: @cards, extends: :div do %>
120
- <div class="spinner"></div>
121
- <% end %>
122
- ```
123
-
124
124
  ## Events
125
125
 
126
126
  Once your futurize element has been rendered, the `futurize:appeared` custom event will be called.
@@ -187,6 +187,8 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
187
187
  </tr>
188
188
  <tr>
189
189
  <td align="center"><a href="http://fractaledmind.com"><img src="https://avatars3.githubusercontent.com/u/5077225?v=4" width="100px;" alt=""/><br /><sub><b>Stephen Margheim</b></sub></a><br /><a href="https://github.com/julianrubisch/futurism/commits?author=fractaledmind" title="Code">💻</a></td>
190
+ <td align="center"><a href="http://hass.codes"><img src="https://avatars2.githubusercontent.com/u/1064205?v=4" width="100px;" alt=""/><br /><sub><b>Hassanin Ahmed</b></sub></a><br /><a href="https://github.com/julianrubisch/futurism/commits?author=sas1ni69" title="Code">💻</a></td>
191
+ <td align="center"><a href="https://marcoroth.dev"><img src="https://avatars2.githubusercontent.com/u/6411752?v=4" width="100px;" alt=""/><br /><sub><b>Marco Roth</b></sub></a><br /><a href="https://github.com/julianrubisch/futurism/commits?author=marcoroth" title="Code">💻</a></td>
190
192
  </tr>
191
193
  </table>
192
194
 
@@ -17,9 +17,10 @@ module Futurism
17
17
  if collection.nil?
18
18
  render_element(extends: extends, placeholder: placeholder, options: options)
19
19
  else
20
- collection_class_name = collection.first.class.name
20
+ collection_class_name = collection.klass.name
21
+ as = options.delete(:as) || collection_class_name.downcase
21
22
  collection.map { |record|
22
- render_element(extends: extends, placeholder: placeholder, options: options.merge(locals: {collection_class_name.downcase.to_sym => record}))
23
+ render_element(extends: extends, placeholder: placeholder, options: options.deep_merge(locals: {as.to_sym => record}))
23
24
  }.join.html_safe
24
25
  end
25
26
  end
@@ -1,3 +1,3 @@
1
1
  module Futurism
2
- VERSION = "0.3.1"
2
+ VERSION = "0.3.2"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: futurism
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Julian Rubisch
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-07-25 00:00:00.000000000 Z
11
+ date: 2020-07-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler