Security News
Weekly Downloads Now Available in npm Package Search Results
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
EasyTable provides a helper for building HTML tables in Rails applications.
It is inspired by simple_form gem: https://github.com/plataformatec/simple_form
Add this line to your application's Gemfile:
gem "easy_table"
And then execute:
$ bundle
For a working Rails 4.2 sample code see: cthulhu666/easy_table_sample
All examples below assume that You are using Haml. Please, use Haml !
= table_for(@people) do |t|
- t.column :name
- t.column :surname
This produces:
%table
%thead
%tr
%th name
%th surname
%tbody
%tr#person-1
%td John
%td Doe
Assuming @people
is a collection consisting of one record, person with id = 1, John Doe
= table_for(@people, class: 'people') do |t|
- t.column :name, class: 'name' do |person|
- person.name.downcase
- t.column :surname, class: lambda { |person| ['surname', person.surname.length > 5 && 'long'].compact } do |person|
- person.surname.upcase
This produces:
%table.people
%thead
%tr
%th name
%th surname
%tbody
%tr#person-1
%td.name john
%td.surname DOE
%tr#person-2
%td.name alice
%td.surname.long COOPER
Assuming @people
is a collection consisting of two records:
= table_for(@people) do |t|
- t.span 'personal data' do |s|
- s.column :name
- s.colunm :surname
- t.span 'contact data' do |s|
- s.column :email
- s.column :phone
This produces:
%table
%thead
%tr
%th{colspan: 2, scope: 'col'} personal data
%th{colspan: 2, scope: 'col'} contact data
%tr
%th name
%th surname
%th email
%th phone
%tbody
%tr#person-1
%td John
%td Doe
%td john.doe@gmail.com
%td 123456789
en:
easy_table:
person: # this is matched based on controller_name.singularize
name: 'Name'
surname: 'Surname'
With following form definition
= table_for(@people) do |t|
- t.column :name
- t.column :surname
It will use 'Name' and 'Surname' as column header labels:
%table
%thead
%tr
%th Name
%th Surname
You can also explicitly set column header passing it as a second argument to column
and span
methods:
= table_for(@people) do |t|
- t.column :name, 'Name'
- t.column :surname, 'Surname'
git checkout -b my-new-feature
)git commit -am 'Added some feature'
)git push origin my-new-feature
)FAQs
Unknown package
We found that easy_table demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
Security News
A Stanford study reveals 9.5% of engineers contribute almost nothing, costing tech $90B annually, with remote work fueling the rise of "ghost engineers."
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.