Skip to content

Commit

Permalink
Add helper to get raw script + make script tag have data-turbo-eval=f…
Browse files Browse the repository at this point in the history
…alse
  • Loading branch information
owaiswiz committed Sep 24, 2024
1 parent aed17c3 commit 0c6e581
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions engine/app/helpers/preflex/preferences_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module PreferencesHelper
extend self

# PREFLEX_PREFERENCE_JS = File.read(Preferences::Preflex::Engine.root.join("app", "static", "preflex_preference.js"))
def script_tag(*preference_klasses)
def script_raw(*preference_klasses)
return ''.html_safe if preference_klasses.empty?

base = <<~JS
Expand Down Expand Up @@ -72,7 +72,13 @@ class PreflexPreference {
"window['#{klass.name}'] = new PreflexPreference('#{klass.name}', #{klass.current.data_for_js});"
end

"<script>#{js.join("\n")}</script>".html_safe
js.join("\n")
end

def script_tag(*preference_klasses)
return ''.html_safe if preference_klasses.empty?

"<script data-turbo-eval=\"false\">#{script_raw(*preference_klasses)}</script>".html_safe
end
end
end

0 comments on commit 0c6e581

Please sign in to comment.