Module: Svelte::Helpers

Includes:
ActionView::Helpers::JavaScriptHelper
Defined in:
lib/svelte/helpers.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.destructure_attrs(hash) ⇒ Object



14
15
16
17
18
19
20
# File 'lib/svelte/helpers.rb', line 14

def self.destructure_attrs(hash)
  string = ""
  hash.each do |k, v|
    string += "#{k}='#{j v}' "
  end
  string
end

Instance Method Details

#svelte_tagsObject



4
5
6
7
8
9
10
# File 'lib/svelte/helpers.rb', line 4

def svelte_tags
  js = <<-JS
    import "https://esm.sh/@11ty/is-land";
  JS

  ((content_for(:head).presence || "") + "\n" + tag.script(js.html_safe, type: "module")).html_safe # steep:ignore RequiredBlockMissing
end