Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

This project is now moved tohttps://github.com/renderedtext/render_async

License

MIT, MIT licenses found

Licenses found

MIT
LICENSE
MIT
LICENSE.txt
NotificationsYou must be signed in to change notification settings

kaspergrubbe/render_async

Repository files navigation

Build Status

This project are now maintained by the kind people over at RenderedText/SemaphoreCI, this project just lives here because the original auther (me!) is a bit nostalgic, please go tohttps://github.com/renderedtext/render_async for updates.

RenderAsync

Renders partials to your viewsasynchronously. This is done through addingJavascript code that does AJAX request to your controller which then rendersyour partial.

Workflow:

  1. user visits a page =>
  2. AJAX request on the controller action =>
  3. controller renders a partial =>
  4. partials renders in the place where you putrender_async helper

Javascript is injected into<%= content_for :render_async %> so you choosewhere to put it.

Installation

Add this line to your application's Gemfile:

gem'render_async',:source=>"https://gem.fury.io/renderedtext/"

And then execute:

$ bundle

Usage

  1. Includerender_async view helper somewhere in your views:

    # app/views/comments/show.html.erb<%=render_asynccomment_stats_path %>
  2. Then create a route that willconfig/routes.rb

    # config/routes.rbget:comment_stats,:controller=>:comments
  3. Fill in the logic in your controller

    # app/controllers/comments_controller.rbdefcomment_stats@stats=Comment.get_statsrender:patial=>"comment_stats"end
  4. Create a partial that will render

    # app/views/comments/_comment_stats.html.erb<divclass="col-md-6">  <%=@stats%></div>
  5. Addcontent_for in your base view file

    # application.html.erb<%=content_for:render_async %>

Development

After checking out the repo, runbin/setup to install dependencies. Then, runrake spec to run the tests. You can also runbin/console for an interactiveprompt that will allow you to experiment.

To install this gem onto your local machine, runbundle exec rake install. Torelease a new version, update the version number inversion.rb, and then runbundle exec rake release, which will create a git tag for the version, pushgit commits and tags, and push the.gem file torubygems.org.

Contributing

Bug reports and pull requests are welcome on GitHub athttps://github.com/renderedtext/render_async.

License

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


[8]ページ先頭

©2009-2025 Movatter.jp