rblade 3.0.0 → 3.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5760d0a2af4a86bf0ffcc9451abb3a46357029b9f5fea33afdf8305282c3d5e3
4
- data.tar.gz: aaf764e044528fac1287219268ed117d332fd13204eb52971de9a88402665780
3
+ metadata.gz: c122be45a5a4cf085c9303105e2ba077e98f985ec1d460b661a34c90011f5bc6
4
+ data.tar.gz: 2025546b49a6058123cc089ade23c51c8a63be70f311336938d79898ee5c08e7
5
5
  SHA512:
6
- metadata.gz: d38f0abf519963a665c5780a2e2328f4bc357455c2cbec99d49362eb76f4529ece7edd65b08ec4c9669700a2c0fca5feeade897fff938aa5c8ed64790f96c152
7
- data.tar.gz: 4ef6e7d9bffb6b9a4360af6ffe7030d9cac15ce6b3c67da546af9739659cb68ea801f06e4ddeaa67f66ce48e4885d4b2931a090518d39b05b994592bd7db0447
6
+ metadata.gz: 7254ddefde7ec012469079917d69c6009bc16853ed230270803b751cf60cf724d642da949247e183a0dd8eff33fff540ce66698b52471ae5c0dd145969040aec
7
+ data.tar.gz: 7f66601910831102f56aaf3c637be8fe1284f043b80927c0b9d41adba7e35bee224f7fa00b6b5f6615b0883e5330879feb560c2de2ac1126700e2368ae1fe226
data/CHANGELOG.md CHANGED
@@ -1,3 +1,6 @@
1
+ ## 3.0.1 [2025-03-18]
2
+ - Fix dynamic components not working when `RBlade.component_helper_method_name` is set
3
+
1
4
  ## 3.0.0 [2025-03-18]
2
5
  - Add ability to add raw directive handlers that add ruby code to the template
3
6
  - Add `RBlade.direct_component_rendering` option to allow RBlade components to be rendered directly
data/README.md CHANGED
@@ -976,7 +976,28 @@ If you would like to prepend content onto the beginning of a stack, you should u
976
976
  <a name="rblade-integration"></a>
977
977
  ## Integrating RBlade With Other Templates
978
978
 
979
- You might want to use RBlade components within other templates, e.g. if you are using a component library that uses them. By default, RBlade components cannot be rendered directly, but this can be enabled using the `direct_component_rendering` option.
979
+ You might want to use RBlade components within other templates, e.g. if you are using a component library that uses them. The `component` helper method lets you easily include RBlade components in your ERB (or other) templates:
980
+
981
+ ```erb
982
+ <%= component "button", class: "mt-4", colour: "green" do %>
983
+ <b>My button</b>
984
+ <% end %>
985
+ ```
986
+
987
+ If preferred, the `component` method can be renamed using the `RBlade.component_helper_method_name` option:
988
+
989
+ ```ruby
990
+ # config/initializers/rblade.rb
991
+
992
+ # Change the name of the component helper method
993
+ RBlade.component_helper_method_name = :rblade_component
994
+
995
+
996
+ # app/views/home/show.erb
997
+ <%= rblade_component "my_component" %>
998
+ ```
999
+
1000
+ By default, RBlade layouts are not compatible with other templates, and components cannot be rendered directly, but this can be enabled using the `direct_component_rendering` option.
980
1001
 
981
1002
  ```ruby
982
1003
  # config/initializers/rblade.rb
@@ -985,13 +1006,14 @@ You might want to use RBlade components within other templates, e.g. if you are
985
1006
  RBlade.direct_component_rendering = true
986
1007
  ```
987
1008
 
988
- Once enabled, RBlade components can be rendered using `render partial: ...`. Block contents are passed to the component in the `slot` variable, `attributes` is initialized using `local_assigns`, and the `@props` directive will look for content set using `content_for`.
1009
+ Once enabled, RBlade components can be used as layouts for ERB templates, or rendered directly using `render`. Block contents are passed to the component in the `slot` variable, `attributes` is initialized using `local_assigns`, and the `@props` directive will look for content set using `content_for`.
989
1010
 
990
1011
  ```erb
991
1012
  <%= render template: "components/button", locals: {class: "mt-4", slot: capture do %>
992
-
1013
+ <% content_for: :title, "My title" %>
1014
+ <b>My content</b>
993
1015
  <% end } %>
994
1016
  ```
995
1017
 
996
1018
  > [!NOTE]
997
- > RBlade's `{{ }}` print directives are automatically sent through Rails' `h` function to prevent XSS attacks.
1019
+ > Using the `component` helper instead of RBlade's component syntax does not take advantage of RBlade's component caching
@@ -67,7 +67,7 @@ module RBlade
67
67
 
68
68
  attributes = compile_attributes token.value[:attributes]
69
69
 
70
- "@output_buffer.raw_buffer<<component(#{component_value}, '#{RBlade.escape_quotes(@component_store.current_view_name)}', #{attributes.join ","}) do;"
70
+ "@output_buffer.raw_buffer<<#{RBlade.component_helper_method_name}(#{component_value}, '#{RBlade.escape_quotes(@component_store.current_view_name)}', #{attributes.join ","}) do;"
71
71
  end
72
72
 
73
73
  def compile_token_end(token)
data/rblade.gemspec CHANGED
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = "rblade"
3
- s.version = "3.0.0"
3
+ s.version = "3.0.1"
4
4
  s.summary = "A component-first templating engine for Rails"
5
5
  s.description = "RBlade is a simple, yet powerful templating engine for Ruby on Rails, inspired by Laravel Blade."
6
6
  s.authors = ["Simon J"]
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rblade
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.0
4
+ version: 3.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Simon J