Actionview::LinkToBlock
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 v4.2(rails v4.2)
gem 'actionview', github: 'rails', branch: 'master'
gem 'actionpack', github: 'rails', branch: 'master'
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.0'
Testing
Test against actionpack v3.2, v4.0, v4.1 and v4.2, 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_master(github)
Contributing
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request