Module: StepRender::ViewHelper

Defined in:
lib/step_render/view_helper.rb

Instance Method Summary collapse

Instance Method Details

#import_step_renderObject



21
22
23
# File 'lib/step_render/view_helper.rb', line 21

def import_step_render
  '<script src="https://cdnjs.cloudflare.com/ajax/libs/lazysizes/3.0.0/lazysizes.min.js" async></script><script src="https://cdnjs.cloudflare.com/ajax/libs/lazysizes/3.0.0/plugins/include/ls.include.min.js" async></script>'.html_safe
end

#step_cache(key, **options) ⇒ Object



10
11
12
13
14
15
16
17
18
19
# File 'lib/step_render/view_helper.rb', line 10

def step_cache(key, **options)
  if Rails.cache.exist?("views/#{key}")
    %(<div class= "related-articles lazyload" data-include="#{step_cache_path(key)}">loading</div>).html_safe
    # content_tag(:div, 'loading', class: 'related-articles lazyload', "data-include" => "#{delayed_cache_path(key)}")
  else
    cache key, **options do
      yield
    end
  end
end

#step_render(*options) ⇒ Object



4
5
6
7
8
# File 'lib/step_render/view_helper.rb', line 4

def step_render(*options)
  key = CGI.escape(Marshal.dump(options))
  path = step_render_path(key)
  %(<div class= "related-articles lazyload" data-include="#{path}">loading</div>).html_safe
end