GithubHelp home page GithubHelp logo

actionview-link_to_block's Introduction

Actionview::LinkToBlock

Gem Version Build Status Code Climate Coverage Status

Add helper method, link_to_block, link_to_block_if, link_to_block_unless, link_to_block_unless_current. This is symmetrical to link_to, link_to_if, link_to_unless, link_to_unless_current.

link_to_block* always accepts block.

Usage

link_to accepts complex html as block, like below:

<%= link_to user_path(@user) do %>
  <i class="icon-ok icon-white"></i> Do it@
<% end %>
# http://stackoverflow.com/questions/9401942/using-link-to-with-embedded-html

But link_to_if with block behavior is below:

<%= link_to_if condition, user_path(@user) do %>
  Appear if condition falsy
<% end %>

Then use link_to_block_if below:

<%= link_to_block_if condition, user_path(@user) do %>
  <i class="icon-ok icon-white"></i> Do it@
<% end %>

#=> if condition truthy, then shows html and link, else if condition falsy, then show only html.

Installation

Add this line to your application's Gemfile:

gem 'actionview-link_to_block'

And then execute:

$ bundle

Or install it yourself as:

$ gem install actionview-link_to_block

Requirement

actionview-link_to_block has no gem dependency in gemspec, but this is not correctly. actionview extracts from actionpack on rails4.1. You can see Appraisals file and /gemfiles directory.

actionview master(rails master)

gem 'actionview', github: 'rails', branch: 'master'
gem 'actionpack', github: 'rails', branch: 'master'

actionview v5.0(rails v5.0)

gem 'actionview', '~> 5.0.0.beta'
gem 'actionpack', '~> 5.0.0.beta'

actionview v4.2(rails v4.2)

gem 'actionview', '~> 4.2.0'
gem 'actionpack', '~> 4.2.0'

actionview v4.1(rails v4.1)

gem 'actionpack', '~> 4.1.0'

actionpack v4.0(rails v4.0)

gem 'actionpack', '~> 4.0.0'

actionpack v3.2(rails v3.2)

gem 'actionpack', '~> 3.2.0'

Testing

Test against actionpack v3.2, v4.0, v4.1, v4.2, v5.0, master run below:

$ bundle
$ bundle exec appraisal install
$ bundle exec appraisal rake

Test for specific version:

$ bundle exec appraisal install
$ bundle exec appraisal actionpack_4_0 rake

Prepare actionpack_3_2(gem), actionpack_4_0(gem), actionview_4_1(gem), actionview_4_2(gem), actionview_5_0(gem), actionview_master(github)

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request

actionview-link_to_block's People

Contributors

sanemat avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

ishikawajump

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.