Git Product home page Git Product logo

futurism's Introduction

Futurism

All Contributors

Lazy-load Rails partials via CableReady

Usage

with a helper in your template

<%= futurize @posts %>

custom <futurism-element>s (in the form of a <div> or a <tr is="futurism-table-row"> are rendered. Those custom elements have an IntersectionObserver attached that will send a signed global id to an ActionCable channel (FuturismChannel) which will then replace the placeholders with the actual resource partial.

With that method, you could lazy load every class that has to_partial_path defined (ActiveModel has by default).

You can pass the placeholder as a block:

<%= futurize @posts, extends: :tr do %>
  <td class="placeholder"></td>
<% end %>

aa601dec1930151f71dbf0d6b02b61c9

Partial Path

Remember that you can override the partial path in you models, like so:

class Post < ApplicationRecord
  def to_partial_path
    "home/post"
  end
end

That way you get maximal flexibility when just specifying a single resource.

Installation

Add this line to your application's Gemfile:

gem 'futurism'

And then execute:

$ bundle

To copy over the javascript files to your application, run

$ bin/rails futurism:install

Contributing

License

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

Contributors โœจ

Thanks goes to these wonderful people (emoji key):


Julian Rubisch

๐Ÿ’ป

darkrubyist

๐Ÿ’ป ๐Ÿ“–

This project follows the all-contributors specification. Contributions of any kind welcome!

futurism's People

Contributors

julianrubisch avatar allcontributors[bot] avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.