Module: Turnstile::ViewHelpers

Defined in:
lib/turnstile/view_helpers.rb

Instance Method Summary collapse

Instance Method Details

#captcha_javascript_tag(options = {}) ⇒ Object



13
14
15
# File 'lib/turnstile/view_helpers.rb', line 13

def captcha_javascript_tag(options = {})
  javascript_include_tag Turnstile.configuration.script_url, **options.reverse_merge(async: true, defer: true)
end

#captcha_placeholder_tag(options = {}) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/turnstile/view_helpers.rb', line 17

def captcha_placeholder_tag(options = {})
  action = options.delete(:action)
  attrs = {
    class: "cf-turnstile",
    data: {
      action: action,
      sitekey: Turnstile.configuration.site_key
    }
  }.deep_merge(options)

   :div, "", attrs
end

#captcha_tags(options = {}) ⇒ Object



4
5
6
7
8
9
10
11
# File 'lib/turnstile/view_helpers.rb', line 4

def captcha_tags(options = {})
  javascript_tag_options = options.delete(:javascript_tag) || {}

  [
    captcha_javascript_tag(javascript_tag_options),
    captcha_placeholder_tag(options)
  ].join.html_safe
end