Class: Superview::Helpers::Turbo::MetaTags

Inherits:
ApplicationComponent
  • Object
show all
Defined in:
lib/superview/helpers/turbo/meta_tags.rb

Overview

Renders the metatags for setting up Turbo Drive.

Constant Summary collapse

METHOD =
:replace
SCROLL =
:reset

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(method: METHOD, scroll: SCROLL, exempts_page_from_preview: nil, exempts_page_from_cache: nil, page_requires_reload: nil) ⇒ MetaTags

Returns a new instance of MetaTags.


16
17
18
19
20
21
# File 'lib/superview/helpers/turbo/meta_tags.rb', line 16

def initialize(method: METHOD, scroll: SCROLL, exempts_page_from_preview: nil, exempts_page_from_cache: nil, page_requires_reload: nil)
  refreshes_with method: method, scroll: scroll
  @exempts_page_from_cache = exempts_page_from_cache
  @exempts_page_from_preview = exempts_page_from_preview
  @page_requires_reload = page_requires_reload
end

Instance Attribute Details

#exempts_page_from_cacheObject

Returns the value of attribute exempts_page_from_cache.


6
7
8
# File 'lib/superview/helpers/turbo/meta_tags.rb', line 6

def exempts_page_from_cache
  @exempts_page_from_cache
end

#exempts_page_from_previewObject

Returns the value of attribute exempts_page_from_preview.


6
7
8
# File 'lib/superview/helpers/turbo/meta_tags.rb', line 6

def exempts_page_from_preview
  @exempts_page_from_preview
end

#methodObject

Returns the value of attribute method.


6
7
8
# File 'lib/superview/helpers/turbo/meta_tags.rb', line 6

def method
  @method
end

#page_requires_reloadObject

Returns the value of attribute page_requires_reload.


6
7
8
# File 'lib/superview/helpers/turbo/meta_tags.rb', line 6

def page_requires_reload
  @page_requires_reload
end

#scrollObject

Returns the value of attribute scroll.


6
7
8
# File 'lib/superview/helpers/turbo/meta_tags.rb', line 6

def scroll
  @scroll
end

Instance Method Details

#refreshes_with(method: METHOD, scroll: SCROLL) ⇒ Object


31
32
33
34
# File 'lib/superview/helpers/turbo/meta_tags.rb', line 31

def refreshes_with(method: METHOD, scroll: SCROLL)
  self.method = method
  self.scroll = scroll
end

#view_templateObject


23
24
25
26
27
28
29
# File 'lib/superview/helpers/turbo/meta_tags.rb', line 23

def view_template
  meta(name: "turbo-refresh-method", content: @method)
  meta(name: "turbo-refresh-scroll", content: @scroll)
  meta(name: "turbo-cache-control", content: "no-cache") if @exempts_page_from_cache
  meta(name: "turbo-cache-control", content: "no-preview") if @exempts_page_from_preview
  meta(name: "turbo-visit-control", content: "reload") if @page_requires_reload
end