xrb-rails 0.0.1

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: d077e35ada159c175012ee0917674cba775d7df24e747d6422033107bbda3166
4
+ data.tar.gz: 2f235273635127aca234261fcc0f82ca95d5114f931b9e7fd3485e15de620e7f
5
+ SHA512:
6
+ metadata.gz: b2547e5a10c6950cc75ccd119e37d0117d98676f7fa82f9bc9f56c7ea494bd1d4130ea5cc114e318e95a6d8109a744a18a0552c3fd6fc40310b209c1ad09b8df
7
+ data.tar.gz: 5395c370b55250355cfeb8a94268aa57e0165eb55a21e60cbbeef15ab047cd0e486bbd4feb4f7b5a5810fcbbffb87b1936ff28edf97a7631e0b6fe85d66d5e09
checksums.yaml.gz.sig ADDED
Binary file
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Released under the MIT License.
4
+ # Copyright, 2024, by Samuel Williams.
5
+
6
+ require_relative 'template_handler'
7
+
8
+ module XRB
9
+ module Rails
10
+ class Railtie < ::Rails::Railtie
11
+ initializer 'initialize XRB template handler' do
12
+ ActiveSupport.on_load(:action_view) do
13
+ ::ActionView::Template.register_template_handler(:xrb, XRB::Rails::TemplateHandler)
14
+ end
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,55 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Released under the MIT License.
4
+ # Copyright, 2024, by Samuel Williams.
5
+
6
+ require 'xrb/template'
7
+ require 'xrb/builder'
8
+
9
+ module XRB
10
+ module Rails
11
+ # We proxy the output buffer to the view instance variable `@output_buffer` as Rails manipulates this during `capture` blocks.
12
+ class Builder
13
+ def initialize(output_buffer)
14
+ @output_buffer = output_buffer
15
+ end
16
+
17
+ def <<(content)
18
+ if content.is_a?(::XRB::Builder::Fragment)
19
+ # XRB's safe output mechanism for lazy evaluation of fragments:
20
+ inline! do
21
+ content.call(self)
22
+ end
23
+ elsif content.is_a?(Markup)
24
+ # XRB's safe output mechanism:
25
+ @output_buffer.safe_concat(content)
26
+ else
27
+ # Unsafe output:
28
+ @output_buffer << content
29
+ end
30
+ end
31
+
32
+ def raw(content)
33
+ @output_buffer.safe_concat(content)
34
+ end
35
+
36
+ def to_s
37
+ @output_buffer
38
+ end
39
+ end
40
+
41
+ class Template < ::XRB::Template
42
+ def to_code
43
+ "#{XRB::OUT}=::XRB::Rails::Builder.new(output_buffer);#{self.code};#{XRB::OUT}.to_s"
44
+ end
45
+ end
46
+
47
+ module TemplateHandler
48
+ # Generate a Ruby code string, which when evaluated, will render the template.
49
+ # The result of evaluating the string should be the output of the template.
50
+ def self.call(template, source)
51
+ Template.load(source).to_code
52
+ end
53
+ end
54
+ end
55
+ end
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Released under the MIT License.
4
+ # Copyright, 2024, by Samuel Williams.
5
+
6
+ module XRB
7
+ module Rails
8
+ VERSION = "0.0.1"
9
+ end
10
+ end
data/lib/xrb/rails.rb ADDED
@@ -0,0 +1,6 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Released under the MIT License.
4
+ # Copyright, 2024, by Samuel Williams.
5
+
6
+ require_relative 'rails/railtie' if defined?(Rails)
data/license.md ADDED
@@ -0,0 +1,21 @@
1
+ # MIT License
2
+
3
+ Copyright, 2024, by Samuel Williams.
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
data/readme.md ADDED
@@ -0,0 +1,29 @@
1
+ # XRB::Rails
2
+
3
+ A railtie for using [xrb](https://github.com/ioquatix/xrb) as a template engine in Rails.
4
+
5
+ [![Development Status](https://github.com/socketry/xrb-rails/workflows/Test/badge.svg)](https://github.com/socketry/xrb-rails/actions?workflow=Test)
6
+
7
+ ## Usage
8
+
9
+ Please see the [project documentation](https://socketry.github.io/xrb-rails/) for more details.
10
+
11
+ - [Getting Started](https://socketry.github.io/xrb-rails/guides/getting-started/index) - This guide will help you get started using `XRB` templates in your Rails application.
12
+
13
+ ## Contributing
14
+
15
+ We welcome contributions to this project.
16
+
17
+ 1. Fork it.
18
+ 2. Create your feature branch (`git checkout -b my-new-feature`).
19
+ 3. Commit your changes (`git commit -am 'Add some feature'`).
20
+ 4. Push to the branch (`git push origin my-new-feature`).
21
+ 5. Create new Pull Request.
22
+
23
+ ### Developer Certificate of Origin
24
+
25
+ This project uses the [Developer Certificate of Origin](https://developercertificate.org/). All contributors to this project must agree to this document to have their contributions accepted.
26
+
27
+ ### Contributor Covenant
28
+
29
+ This project is governed by the [Contributor Covenant](https://www.contributor-covenant.org/). All contributors and participants agree to abide by its terms.
data.tar.gz.sig ADDED
Binary file
metadata ADDED
@@ -0,0 +1,94 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: xrb-rails
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Samuel Williams
8
+ autorequire:
9
+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Q8EBAMCBLAwHQYDVR0O
28
+ BBYEFO9t7XWuFf2SKLmuijgqR4sGDlRsMC4GA1UdEQQnMCWBI3NhbXVlbC53aWxs
29
+ aWFtc0BvcmlvbnRyYW5zZmVyLmNvLm56MC4GA1UdEgQnMCWBI3NhbXVlbC53aWxs
30
+ aWFtc0BvcmlvbnRyYW5zZmVyLmNvLm56MA0GCSqGSIb3DQEBCwUAA4IBgQB5sxkE
31
+ cBsSYwK6fYpM+hA5B5yZY2+L0Z+27jF1pWGgbhPH8/FjjBLVn+VFok3CDpRqwXCl
32
+ xCO40JEkKdznNy2avOMra6PFiQyOE74kCtv7P+Fdc+FhgqI5lMon6tt9rNeXmnW/
33
+ c1NaMRdxy999hmRGzUSFjozcCwxpy/LwabxtdXwXgSay4mQ32EDjqR1TixS1+smp
34
+ 8C/NCWgpIfzpHGJsjvmH2wAfKtTTqB9CVKLCWEnCHyCaRVuKkrKjqhYCdmMBqCws
35
+ JkxfQWC+jBVeG9ZtPhQgZpfhvh+6hMhraUYRQ6XGyvBqEUe+yo6DKIT3MtGE2+CP
36
+ eX9i9ZWBydWb8/rvmwmX2kkcBbX0hZS1rcR593hGc61JR6lvkGYQ2MYskBveyaxt
37
+ Q2K9NVun/S785AP05vKkXZEFYxqG6EW012U4oLcFl5MySFajYXRYbuUpH6AY+HP8
38
+ voD0MPg1DssDLKwXyt1eKD/+Fq0bFWhwVM/1XiAXL7lyYUyOq24KHgQ2Csg=
39
+ -----END CERTIFICATE-----
40
+ date: 2024-04-28 00:00:00.000000000 Z
41
+ dependencies:
42
+ - !ruby/object:Gem::Dependency
43
+ name: xrb
44
+ requirement: !ruby/object:Gem::Requirement
45
+ requirements:
46
+ - - "~>"
47
+ - !ruby/object:Gem::Version
48
+ version: '0.3'
49
+ type: :runtime
50
+ prerelease: false
51
+ version_requirements: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - "~>"
54
+ - !ruby/object:Gem::Version
55
+ version: '0.3'
56
+ description:
57
+ email:
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - lib/xrb/rails.rb
63
+ - lib/xrb/rails/railtie.rb
64
+ - lib/xrb/rails/template_handler.rb
65
+ - lib/xrb/rails/version.rb
66
+ - license.md
67
+ - readme.md
68
+ homepage: https://github.com/ioquatix/xrb-rails
69
+ licenses:
70
+ - MIT
71
+ metadata:
72
+ documentation_uri: https://socketry.github.io/xrb-rails/
73
+ funding_uri: https://github.com/sponsors/ioquatix/
74
+ source_code_uri: https://github.com/ioquatix/xrb-rails.git
75
+ post_install_message:
76
+ rdoc_options: []
77
+ require_paths:
78
+ - lib
79
+ required_ruby_version: !ruby/object:Gem::Requirement
80
+ requirements:
81
+ - - ">="
82
+ - !ruby/object:Gem::Version
83
+ version: '3.1'
84
+ required_rubygems_version: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - ">="
87
+ - !ruby/object:Gem::Version
88
+ version: '0'
89
+ requirements: []
90
+ rubygems_version: 3.5.3
91
+ signing_key:
92
+ specification_version: 4
93
+ summary: Add support XRB templates in Rails.
94
+ test_files: []
metadata.gz.sig ADDED
@@ -0,0 +1,2 @@
1
+ 6V{�.0ɣ��| �V��G�`Q]�j+lj��ő����/{���
2
+ D��t� ��n_�`���#���b���� ����x Ǹ�@��-�UQ��t���> &�1"��]L=�F)�_/��,�5D�}���v�={l+��2\J�h�~'���iO���>ʒ��7�Tb���?ۑ�1�/�6�����Rn@��������d���3rCR^���N^���b����y��Fj�뎴>-�w� o�i2����a�O�r�B��{�Ct]v��� ��ce1�{~_/d -E���e#�I��{@�&޻R���Y�hx�3p�.#XV�oD�w�����`=ֺu���OMRc&r)n���M+_��n�]��A���νO��i