Project

sexy_li

0.0
No commit activity in last 3 years
No release in over 3 years
Make easy creating typicaly list.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

Runtime

>= 3.2.0
 Project Readme

Sexy li

Make easy creating typicaly list.

Before:

<ul>
  <% - @posts.each do |post| %>
    <%= content_tag_for :li, post %>
      <div class="id"><%= post.id %></div>
      <div class="title"><%= post.title %></div>
    <% end %>
  <% end %>
</ul>

After:

<ul><%= render_li_for @posts %></ul>

_post.html.erb:

<div class="id"><%= post.id %></div>
<div class="title"><%= post.title %></div>

Haml or Slim are same above.

Installation

Add this line in your Gemfile.

gem 'sexy_li'

And bundle.

$ bundle

Usage

render_li_for

See above.

render_li_for with custom partial

<ul><%= render_li_for @posts, { partial: 'post_small' } %></ul>

_post_small.html.erb:

<div class="id"><%= post.id %></div>
<div class="title"><%= post.title %></div>

render_tr_for

It put tr tag instead of li tag.

render_content_for

<ul><%= render_li_for @posts %></ul>

It is same blow.

<ul><%= render_content_for :li, @posts %></ul>

li_for

<%= content_tag_for :li, @post %>

It is same blow.

<%= li_for @post %>

tr_for

<%= content_tag_for :tr, @post %>

It is same blow.

<%= tr_for @post %>

License

Dual licensed under the MIT or GPL licenses:

Copyright © 2013 Masaki Komagata