kit_liquid_rails 0.1.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 +7 -0
- data/.gitignore +1 -0
- data/Gemfile +4 -0
- data/MIT_LICENSE.md +9 -0
- data/MIT_LICENSE.txt +20 -0
- data/README.md +36 -0
- data/kit_liquid_rails.gemspec +29 -0
- data/lib/kit_liquid_rails/railtie.rb +11 -0
- data/lib/kit_liquid_rails/template_handler.rb +33 -0
- data/lib/kit_liquid_rails/version.rb +5 -0
- data/lib/kit_liquid_rails.rb +6 -0
- metadata +137 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: d49fc48c859e950e495e30e7c045e011760b8b3afe4c9ec2332cbc785edc22a5
|
4
|
+
data.tar.gz: a36b9cfb640ffc0ac0d3a80479fc67159d5cce384411d766446150be66d56934
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: bd8ec87e59b3ccd97527a6be9334ddf7c12c4fde02a65a19de77dcbf3f523b230ec5b2dd32602acc0e9aae7f3bbc52ca53201d7e38a5f63399fff0d5931fc2af
|
7
|
+
data.tar.gz: ab62af6a97fe1490e3fbd36b0c37213098f4171e2cb77eed1a41027de87fbfd139189f6d9b15c8477cf860b91a76215dff80b77f921c543ba6395bbfefd98a1a
|
data/.gitignore
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
Gemfile.lock
|
data/Gemfile
ADDED
data/MIT_LICENSE.md
ADDED
@@ -0,0 +1,9 @@
|
|
1
|
+
# License
|
2
|
+
|
3
|
+
- [MIT license](http://www.opensource.org/licenses/mit-license.php)
|
4
|
+
- **Copyright (c) 2021 Nathan Appere**
|
5
|
+
- https://github.com/rubykit/liquid_rails
|
6
|
+
- https://github.com/rubykit/liquid_rails/blob/master/MIT_LICENSE.md
|
7
|
+
|
8
|
+
The license itself:
|
9
|
+
- https://github.com/rubykit/liquid_rails/blob/master/MIT_LICENSE.txt
|
data/MIT_LICENSE.txt
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2021 Nathan Appere, https://github.com/rubykit/liquid_rails
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
[LiquidRails]: https://github.com/rubykit/liquid_rails
|
2
|
+
[Liquid]: https://shopify.github.io/liquid/
|
3
|
+
[ViewComponent]: https://github.com/github/view_component
|
4
|
+
[Ruby on Rails]: https://rubyonrails.org/
|
5
|
+
|
6
|
+
# LiquidRails
|
7
|
+
|
8
|
+
[LiquidRails] allows you to render [Liquid] templates in [Ruby on Rails] views & [ViewComponent]s.
|
9
|
+
|
10
|
+
## Installation
|
11
|
+
|
12
|
+
Add this line to your application's Gemfile:
|
13
|
+
|
14
|
+
```ruby
|
15
|
+
group :test, :development do
|
16
|
+
gem 'kit_liquid_rails'
|
17
|
+
end
|
18
|
+
```
|
19
|
+
|
20
|
+
Or, for a Ruby library, add this to your gemspec:
|
21
|
+
|
22
|
+
```ruby
|
23
|
+
spec.add_dependency 'kit_liquid_rails'
|
24
|
+
```
|
25
|
+
|
26
|
+
And then run:
|
27
|
+
|
28
|
+
```bash
|
29
|
+
$ bundle install
|
30
|
+
```
|
31
|
+
|
32
|
+
## Copyright & License
|
33
|
+
|
34
|
+
Copyright (c) 2021, Nathan Appere.
|
35
|
+
|
36
|
+
[LiquidRails] is licensed under [MIT License](MIT_LICENSE.md).
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require_relative 'lib/kit_liquid_rails/version'
|
2
|
+
|
3
|
+
version = KitLiquidRails::VERSION
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = 'kit_liquid_rails'
|
7
|
+
s.version = version
|
8
|
+
s.summary = 'Add support for Liquid templates in Ruby on Rails.'
|
9
|
+
s.description = 'Allows you to use .liquid templates in your views & ViewComponents.'
|
10
|
+
s.license = 'MIT'
|
11
|
+
s.author = 'Nathan Appere'
|
12
|
+
s.email = 'nathan@rubykit.org'
|
13
|
+
s.homepage = 'https://github.com/rubykit/liquid_rails'
|
14
|
+
|
15
|
+
s.metadata = {
|
16
|
+
'source_code_uri' => "https://github.com/rubykit/liquid_rails/tree/v#{ version }"
|
17
|
+
}
|
18
|
+
|
19
|
+
s.add_dependency 'liquid', '~> 5.0'
|
20
|
+
s.add_dependency 'railties', '~> 6.0'
|
21
|
+
s.add_dependency 'view_component', '~> 2.40'
|
22
|
+
|
23
|
+
s.add_development_dependency 'bundler'
|
24
|
+
s.add_development_dependency 'rails', '~> 6.0'
|
25
|
+
s.add_development_dependency 'rake'
|
26
|
+
|
27
|
+
s.files = `git ls-files`.split("\n")
|
28
|
+
s.require_path = 'lib'
|
29
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
require 'rails'
|
2
|
+
|
3
|
+
class KitLiquidRails::Railtie < ::Rails::Railtie
|
4
|
+
|
5
|
+
initializer "kit_liquid_rails.register_template_handler" do
|
6
|
+
ActiveSupport.on_load(:action_view) do
|
7
|
+
ActionView::Template.register_template_handler :liquid, KitLiquidRails::TemplateHandler
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
class KitLiquidRails::TemplateHandler
|
2
|
+
|
3
|
+
attr_reader :context
|
4
|
+
|
5
|
+
# Note: local_assigns is not available in ViewComponents
|
6
|
+
def self.call(template, source)
|
7
|
+
source ||= template.source
|
8
|
+
"::KitLiquidRails::TemplateHandler.new(self).render(#{ source.inspect }, (defined?(local_assigns) ? local_assigns : nil))"
|
9
|
+
end
|
10
|
+
|
11
|
+
def initialize(context)
|
12
|
+
@context = context
|
13
|
+
end
|
14
|
+
|
15
|
+
def render(source, local_assigns = nil)
|
16
|
+
local_assigns ||= {}
|
17
|
+
|
18
|
+
# Use `liquid_assigns` method on the `ViewComponent` to determine what to forward to Liquid.
|
19
|
+
if context.is_a?(::ViewComponent::Base) && context.respond_to?(:liquid_assigns)
|
20
|
+
local_assigns = context.liquid_assigns
|
21
|
+
end
|
22
|
+
|
23
|
+
local_assigns = local_assigns&.deep_stringify_keys
|
24
|
+
|
25
|
+
liquid = Liquid::Template.parse(source)
|
26
|
+
liquid.render(local_assigns).html_safe
|
27
|
+
end
|
28
|
+
|
29
|
+
def compilable?
|
30
|
+
false
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
metadata
ADDED
@@ -0,0 +1,137 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: kit_liquid_rails
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Nathan Appere
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2021-09-12 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: liquid
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '5.0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '5.0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: railties
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '6.0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '6.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: view_component
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '2.40'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '2.40'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: bundler
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rails
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '6.0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '6.0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: rake
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
description: Allows you to use .liquid templates in your views & ViewComponents.
|
98
|
+
email: nathan@rubykit.org
|
99
|
+
executables: []
|
100
|
+
extensions: []
|
101
|
+
extra_rdoc_files: []
|
102
|
+
files:
|
103
|
+
- ".gitignore"
|
104
|
+
- Gemfile
|
105
|
+
- MIT_LICENSE.md
|
106
|
+
- MIT_LICENSE.txt
|
107
|
+
- README.md
|
108
|
+
- kit_liquid_rails.gemspec
|
109
|
+
- lib/kit_liquid_rails.rb
|
110
|
+
- lib/kit_liquid_rails/railtie.rb
|
111
|
+
- lib/kit_liquid_rails/template_handler.rb
|
112
|
+
- lib/kit_liquid_rails/version.rb
|
113
|
+
homepage: https://github.com/rubykit/liquid_rails
|
114
|
+
licenses:
|
115
|
+
- MIT
|
116
|
+
metadata:
|
117
|
+
source_code_uri: https://github.com/rubykit/liquid_rails/tree/v0.1.0
|
118
|
+
post_install_message:
|
119
|
+
rdoc_options: []
|
120
|
+
require_paths:
|
121
|
+
- lib
|
122
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
123
|
+
requirements:
|
124
|
+
- - ">="
|
125
|
+
- !ruby/object:Gem::Version
|
126
|
+
version: '0'
|
127
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - ">="
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '0'
|
132
|
+
requirements: []
|
133
|
+
rubygems_version: 3.2.3
|
134
|
+
signing_key:
|
135
|
+
specification_version: 4
|
136
|
+
summary: Add support for Liquid templates in Ruby on Rails.
|
137
|
+
test_files: []
|