roda-phlex-render 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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 70dcf13204412046dfd9ddda4017ddb5ace02647b9b8564b292e961dcecb0414
4
+ data.tar.gz: f5c8b668f5bf86ee8d84c6197688e218207ea399b7a3f3b04ae795a5057e4a31
5
+ SHA512:
6
+ metadata.gz: fa4da1eb5642254718fe9026ce36a83db379958268f91fd4f6d9a8f3c0d5ff0dd1607590a5db0b910351bc18949167bbdeb90984d6b82cb1b2827419a17e57f0
7
+ data.tar.gz: 71dc3e0b72e2d96178f67f142553558d09206bb32c1681e0debe448fad4231db71e176721e7075eb52e004bbf6e2865887d41af257a5857b0c6822dd2451383e
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "roda"
4
+ require "phlex"
5
+ require "roda/plugins/phlex_render"
@@ -0,0 +1,62 @@
1
+ # frozen_string_literal: true
2
+
3
+ class Roda
4
+ module RodaPlugins
5
+ # The phlex plugin allows match blocks to return Phlex::HTML
6
+ # objects, which are automatically rendered and used as the
7
+ # response body.
8
+ #
9
+ # Without the plugin:
10
+ #
11
+ # r.is "play" do
12
+ # View::Layout::Main.new(
13
+ # title: "Play",
14
+ # body: View::Play
15
+ # ).call
16
+ # end
17
+ #
18
+ # With the plugin:
19
+ #
20
+ # plugin :phlex
21
+ #
22
+ # r.is "play" do
23
+ # View::Layout::Main.new(
24
+ # title: "Play",
25
+ # body: View::Play
26
+ # )
27
+ # end
28
+ #
29
+ # By default, Phlex::HTML objects are rendered using #call and
30
+ # the response Content-Type is set to text/html; charset=utf-8.
31
+ module Phlex
32
+ def self.load_dependencies(app, opts = OPTS)
33
+ app.plugin :custom_block_results
34
+ end
35
+
36
+ def self.configure(app, opts = OPTS)
37
+ app.opts[:phlex_result_content_type] =
38
+ opts[:content_type] || "text/html; charset=utf-8"
39
+
40
+ app.opts[:custom_block_results][::Phlex::HTML] =
41
+ :handle_phlex_block_result
42
+ end
43
+
44
+ module ClassMethods
45
+ def phlex_result_classes
46
+ opts[:phlex_result_classes]
47
+ end
48
+ end
49
+
50
+ module InstanceMethods
51
+ def handle_phlex_block_result(result)
52
+ @_response[RodaResponseHeaders::CONTENT_TYPE] ||=
53
+ opts[:phlex_result_content_type]
54
+
55
+ result.call
56
+ end
57
+ end
58
+ end
59
+
60
+ register_plugin(:phlex_render, Phlex)
61
+ end
62
+ end
metadata ADDED
@@ -0,0 +1,68 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: roda-phlex-render
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Dmitriy Ryzhenko
8
+ bindir: bin
9
+ cert_chain: []
10
+ date: 1980-01-02 00:00:00.000000000 Z
11
+ dependencies:
12
+ - !ruby/object:Gem::Dependency
13
+ name: roda
14
+ requirement: !ruby/object:Gem::Requirement
15
+ requirements:
16
+ - - ">="
17
+ - !ruby/object:Gem::Version
18
+ version: '0'
19
+ type: :runtime
20
+ prerelease: false
21
+ version_requirements: !ruby/object:Gem::Requirement
22
+ requirements:
23
+ - - ">="
24
+ - !ruby/object:Gem::Version
25
+ version: '0'
26
+ - !ruby/object:Gem::Dependency
27
+ name: phlex
28
+ requirement: !ruby/object:Gem::Requirement
29
+ requirements:
30
+ - - ">="
31
+ - !ruby/object:Gem::Version
32
+ version: '0'
33
+ type: :runtime
34
+ prerelease: false
35
+ version_requirements: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - ">="
38
+ - !ruby/object:Gem::Version
39
+ version: '0'
40
+ description: A Roda plugin for rendering Phlex::HTML block results.
41
+ executables: []
42
+ extensions: []
43
+ extra_rdoc_files: []
44
+ files:
45
+ - lib/phlex_render.rb
46
+ - lib/roda/plugins/phlex_render.rb
47
+ homepage: https://github.com/0riginaln0/roda-phlex-render
48
+ licenses:
49
+ - MIT
50
+ metadata: {}
51
+ rdoc_options: []
52
+ require_paths:
53
+ - lib
54
+ required_ruby_version: !ruby/object:Gem::Requirement
55
+ requirements:
56
+ - - ">="
57
+ - !ruby/object:Gem::Version
58
+ version: '3.2'
59
+ required_rubygems_version: !ruby/object:Gem::Requirement
60
+ requirements:
61
+ - - ">="
62
+ - !ruby/object:Gem::Version
63
+ version: '0'
64
+ requirements: []
65
+ rubygems_version: 4.0.16
66
+ specification_version: 4
67
+ summary: Return Phlex views directly from Roda route blocks
68
+ test_files: []