Module: QueryDiet::Widget::Helper

Defined in:
lib/query_diet/widget.rb

Instance Method Summary collapse

Instance Method Details

#query_diet_widget(options = {}) ⇒ Object



55
56
57
58
59
60
61
62
63
# File 'lib/query_diet/widget.rb', line 55

def query_diet_widget(options = {})
  default_html_options = {:nonce => false}
  options = options.reverse_merge(default_html_options)

  nonce_attribute = options.fetch(:nonce) ? " nonce=\"#{content_security_policy_nonce}\"" : ''

  html = Widget.css(nonce_attribute) + Widget.html(options) + Widget.js(nonce_attribute)
  html.respond_to?(:html_safe) ? html.html_safe : html
end