phlex-rails-template 0.1.2 → 0.1.4
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/README.md +6 -6
- data/lib/phlex/rails/template/engine.rb +1 -3
- data/lib/phlex/rails/template/handler.rb +2 -1
- data/lib/phlex/rails/template/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 97284acc3aa1095b5856f114cccbaeaf12a07ac1fb43ce8625b26f5843e6774c
|
|
4
|
+
data.tar.gz: 183918f0c84b4303354fc082773bbb7e81b8f650e2566c140d942f026dd633e3
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 319821a69250f0e98d2e20cd4b3c4f27a6bab6476533f41fb76d932edf2977e0452407a08fa36d13d4d6d00f33d98aab655a4c3b19b295e379c7bdecfaa73f37
|
|
7
|
+
data.tar.gz: 4e2d5b6e2bcf78e1745fc29bea94ac167818d2fb9ec436970eb09ff6b0c5b66237e05c490df1c18bdf85ce5b6a61ff7e3bfedd056e60addb23e50eafd7df8860
|
data/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Phlex::Rails::Template
|
|
2
2
|
|
|
3
|
-
A Rails template handler that lets you write Phlex components directly in `.html.
|
|
3
|
+
A Rails template handler that lets you write Phlex components directly in `.html.phlex` view files.
|
|
4
4
|
|
|
5
5
|
## Installation
|
|
6
6
|
|
|
@@ -13,10 +13,10 @@ bundle add 'phlex-rails-template'
|
|
|
13
13
|
|
|
14
14
|
## Usage
|
|
15
15
|
|
|
16
|
-
Create view files with the `.html.
|
|
16
|
+
Create view files with the `.html.phlex` extension:
|
|
17
17
|
|
|
18
18
|
```ruby
|
|
19
|
-
# app/views/posts/show.html.
|
|
19
|
+
# app/views/posts/show.html.phlex
|
|
20
20
|
h1 { @post.title }
|
|
21
21
|
|
|
22
22
|
div(class: "content") do
|
|
@@ -30,7 +30,7 @@ In your controller:
|
|
|
30
30
|
class PostsController < ApplicationController
|
|
31
31
|
def show
|
|
32
32
|
@post = Post.find(params[:id])
|
|
33
|
-
# Renders app/views/posts/show.html.
|
|
33
|
+
# Renders app/views/posts/show.html.phlex automatically
|
|
34
34
|
end
|
|
35
35
|
end
|
|
36
36
|
```
|
|
@@ -43,7 +43,7 @@ You can customize how components are instantiated and how variables are assigned
|
|
|
43
43
|
|
|
44
44
|
```ruby
|
|
45
45
|
# config/initializers/phlex_rails_template.rb
|
|
46
|
-
Phlex::Rails::Template.register :
|
|
46
|
+
Phlex::Rails::Template.register :phlex do
|
|
47
47
|
# Override the base component class
|
|
48
48
|
def component_class
|
|
49
49
|
ApplicationComponent
|
|
@@ -72,7 +72,7 @@ class CustomConfigurator < Phlex::Rails::Template::Configurator
|
|
|
72
72
|
end
|
|
73
73
|
end
|
|
74
74
|
|
|
75
|
-
Phlex::Rails::Template.register :
|
|
75
|
+
Phlex::Rails::Template.register :phlex, CustomConfigurator
|
|
76
76
|
```
|
|
77
77
|
|
|
78
78
|
You can also register additional template handlers with different configurators:
|
|
@@ -5,9 +5,7 @@ module Phlex
|
|
|
5
5
|
module Template
|
|
6
6
|
class Engine < ::Rails::Engine
|
|
7
7
|
initializer "phlex.rails.template.register_handler" do
|
|
8
|
-
|
|
9
|
-
ActionView::Template.register_template_handler :rb, Phlex::Rails::Template::Handler
|
|
10
|
-
end
|
|
8
|
+
ActionView::Template.register_template_handler :phlex, Phlex::Rails::Template::Handler
|
|
11
9
|
end
|
|
12
10
|
end
|
|
13
11
|
end
|
|
@@ -6,9 +6,10 @@ module Phlex
|
|
|
6
6
|
class Handler
|
|
7
7
|
def self.call(template, source = nil)
|
|
8
8
|
src = source || template.source
|
|
9
|
+
handler_name = template.short_identifier[/\.(\w+)\z/, 1]&.to_sym || :phlex
|
|
9
10
|
|
|
10
11
|
<<~RUBY
|
|
11
|
-
__component__ = Phlex::Rails::Template.build(self,
|
|
12
|
+
__component__ = Phlex::Rails::Template.build(self, :#{handler_name}) do
|
|
12
13
|
#{src}
|
|
13
14
|
end
|
|
14
15
|
__component__.render_in(self).to_s
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: phlex-rails-template
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.1.
|
|
4
|
+
version: 0.1.4
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Brad Gessler
|
|
@@ -51,7 +51,7 @@ dependencies:
|
|
|
51
51
|
- - ">="
|
|
52
52
|
- !ruby/object:Gem::Version
|
|
53
53
|
version: '6.0'
|
|
54
|
-
description: Write Phlex components directly in .html.
|
|
54
|
+
description: Write Phlex components directly in .html.phlex view files
|
|
55
55
|
email:
|
|
56
56
|
- bradgessler@gmail.com
|
|
57
57
|
executables: []
|