content_pack_rails 0.2.2 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.github/workflows/tests.yml +34 -0
- data/CHANGELOG.md +6 -0
- data/README.md +8 -4
- data/content_pack_rails.gemspec +5 -1
- data/lib/content_pack_rails/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8a26d8a1b263627df989ef8d8d97f33b489c8322c92eb503c158b9b2b7cad37b
|
4
|
+
data.tar.gz: f721a69bbed4ed7d6d2c98bf1a3ac10394f4efa8a9946528b3c1193927676d04
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fe733e4d00555d3963a70c7d310063e21feebd17c4392fa1c8930bed30043c12192d17809c0d2906781ed8ab924442835de8a77aa253bb3ff55f5b7296719d90
|
7
|
+
data.tar.gz: 65b7a42f9b7b3bfa5dcf459d9cc52ba02b08793297dae4a7cedb2a7e9aaae74643e0aa178b2750849f2737bfc5ec76f15c2b9e2f88843dccae48dbf7105ec243
|
@@ -0,0 +1,34 @@
|
|
1
|
+
name: Tests
|
2
|
+
|
3
|
+
on:
|
4
|
+
push:
|
5
|
+
branches: [ main ]
|
6
|
+
pull_request:
|
7
|
+
branches: [ main ]
|
8
|
+
|
9
|
+
jobs:
|
10
|
+
test:
|
11
|
+
strategy:
|
12
|
+
fail-fast: false
|
13
|
+
matrix:
|
14
|
+
ruby: ['2.7', '3.0']
|
15
|
+
rails: ['6.1', '7.0']
|
16
|
+
|
17
|
+
runs-on: ubuntu-latest
|
18
|
+
name: Test against Ruby ${{ matrix.ruby }} / Rails ${{ matrix.rails }}
|
19
|
+
|
20
|
+
steps:
|
21
|
+
- uses: actions/checkout@v2
|
22
|
+
|
23
|
+
- name: Set up Ruby
|
24
|
+
uses: ruby/setup-ruby@v1
|
25
|
+
with:
|
26
|
+
ruby-version: ${{ matrix.ruby }}
|
27
|
+
|
28
|
+
- name: Install gems and run tests
|
29
|
+
env:
|
30
|
+
TEST_RAILS_VERSION: ${{ matrix.rails }}
|
31
|
+
run: |
|
32
|
+
gem install bundler
|
33
|
+
bundle install --jobs 4 --retry 3
|
34
|
+
bundle exec rake
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -1,4 +1,8 @@
|
|
1
1
|
# ContentPackRails
|
2
|
+
|
3
|
+
[](https://badge.fury.io/rb/content_pack_rails)
|
4
|
+
[](https://github.com/a-bohush/content_pack_rails/actions/workflows/tests.yml)
|
5
|
+
|
2
6
|
A thin wrapper around [`ActionView::Helpers::CaptureHelper#content_for`](https://api.rubyonrails.org/classes/ActionView/Helpers/CaptureHelper.html#method-i-content_for).
|
3
7
|
Useful when you need to collect multiple content entries during page rendering, for example <script type="text/template"> templates, without woring about possible duplications and name clashes.
|
4
8
|
|
@@ -33,7 +37,7 @@ module ApplicationHelper
|
|
33
37
|
end
|
34
38
|
```
|
35
39
|
|
36
|
-
Helper `content_pack` declares the same parameters as
|
40
|
+
Helper `content_pack` declares the same parameters as the standard rails `content_for` and can be used similarly to capture content like this:
|
37
41
|
|
38
42
|
```erb
|
39
43
|
<% content_pack 'content-id' do |id| %>
|
@@ -45,14 +49,14 @@ Helper `content_pack` declares the same parameters as a standard rails `content_
|
|
45
49
|
-->
|
46
50
|
<% end %>
|
47
51
|
```
|
48
|
-
or pass content as
|
52
|
+
or pass content as the second argument:
|
49
53
|
```erb
|
50
54
|
<% content_pack 'content-id', 'Your content' %>
|
51
55
|
```
|
52
56
|
|
53
57
|
Unlike `content_for`, by default, `content_pack` will not concatenate content with the same name.
|
54
58
|
Multiple calls to `content_pack` with the same content name will result in only the first content being added to the pack.
|
55
|
-
If you would like to add additional content on a given name, you should pass
|
59
|
+
If you would like to add additional content on a given name, you should pass the `append: true` option like so:
|
56
60
|
|
57
61
|
```erb
|
58
62
|
<% content_pack 'content-id', 'first content' %>
|
@@ -60,7 +64,7 @@ If you would like to add additional content on a given name, you should pass an
|
|
60
64
|
<% content_pack 'content-id', 'second content', append: true %>
|
61
65
|
```
|
62
66
|
|
63
|
-
In case you want to override content on a given name, provide
|
67
|
+
In case you want to override content on a given name, provide the `flush: true` option:
|
64
68
|
```erb
|
65
69
|
<% content_pack 'content-id', 'first content' %>
|
66
70
|
<!-- following will override the first one -->
|
data/content_pack_rails.gemspec
CHANGED
@@ -18,6 +18,10 @@ Gem::Specification.new do |spec|
|
|
18
18
|
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
19
19
|
end
|
20
20
|
|
21
|
-
|
21
|
+
if ENV['TEST_RAILS_VERSION'].nil?
|
22
|
+
spec.add_development_dependency "rails", "~> 6.1.4", ">= 6.1.4.1"
|
23
|
+
else
|
24
|
+
spec.add_development_dependency "rails", ENV['TEST_RAILS_VERSION'].to_s
|
25
|
+
end
|
22
26
|
spec.add_development_dependency "pry-byebug"
|
23
27
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: content_pack_rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrew Bohush
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-02-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -52,6 +52,7 @@ extensions: []
|
|
52
52
|
extra_rdoc_files:
|
53
53
|
- README.md
|
54
54
|
files:
|
55
|
+
- ".github/workflows/tests.yml"
|
55
56
|
- ".gitignore"
|
56
57
|
- CHANGELOG.md
|
57
58
|
- Gemfile
|