Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

step_render

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

step_render

  • 0.2.1
  • Rubygems
  • Socket score

Version published
Maintainers
1
Created
Source

StepRender

It is very easy to enable lazy loading of partial with scroll in views.

You only use step_render method instead of render method.

Likewise, you can lazy load a fragment cache.

Installation

Add this line to your application's Gemfile:

gem 'step_render'

And then execute:

$ bundle

Usage 1: Lazy Load Partial

1. Load javascript library

This plugin depends on lazysizes. If you do not import lazysizes to your application, load import_step_render method in required view.

Example

application.html.erb

<head>
  ~~~
  ~~~
  <%= import_step_render %>
  ~~~
</head>

2. Add to routing

Add the following line to the routes.rb.

Example

routes.rb

Rails.application.routes.draw do
  ~~~
  mount_step_render
  ~~~

3. Use step_render method instead of render method

Replace render helper method used to rendering the partial with step_render. Partial must be specified as an absolute path.

Example

app/views/top/index.html.erb

<%= step_render 'top/partial_name' %>

Usage 2: Lazy Load fragment cache

1. Load javascript library

2. Add to routing

3. Use step_cache method instead of cache method

Replace cache helper method used to fragment cache with step_render.

Example

app/views/top/index.html.erb

<%= step_cache 'cache_key', skip_digest: true, expires_in: 24.hours %>
  ~~~
  ~~~html tags

Contributing

Contribution directions go here.

License

The gem is available as open source under the terms of the MIT License.

FAQs

Package last updated on 17 Oct 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc