Skip to content

Commit

Permalink
Use Phlex's safe method if Phlex is 2.0 or above
Browse files Browse the repository at this point in the history
  • Loading branch information
davidalejandroaguilar committed Sep 29, 2024
1 parent 965ffe6 commit 198fc62
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion lib/phlexy_ui/button.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# frozen_string_literal: true

require "phlex/version"

module PhlexyUI
class Button < Base
def initialize(*, as: :button, modal: nil, **)
Expand All @@ -16,7 +18,17 @@ def view_template(&)
options:
).then do |classes|
if modal
build_button_via_unsafe_raw(classes, &)
if Phlex::VERSION.start_with?("1.")
build_button_via_unsafe_raw(classes, &)
else
public_send(
as,
class: classes,
onclick: safe("#{Phlex::Escape.html_escape(modal)}.showModal()"),
**options,
&
)
end
else
public_send(as, class: classes, **options, &)
end
Expand Down

0 comments on commit 198fc62

Please sign in to comment.