Skip to content
master
Go to file
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
app
 
 
bin
 
 
 
 
lib
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

README.md

SimpleCells

Install

Add to your Gemfile and bundle:

gem "simple_cells"

Add the render method by including the helper in your ApplicationHelper:

module ApplicationHelper
  include SimpleCells::ViewsHelper
end

Autoload the simple cells through "application.rb":

config.autoload_paths << Rails.root.join("app", "simple_cells")

Usage

Add a cells-class to your application in "app/simple_cells/users_simple_cell.rb":

class UsersSimpleCell < SimpleCells::BaseCell
  def my_action
  end

  def helper_method
    "Hello from helper method"
  end
end

Then add a view file for the action in "app/views/simple_cells/users/my_action.html.erb":

Hello world
Content of my variable: <%= simple_cell[:my_variable] %>
Helper method: <%= simple_cell.helper_method %>

You can now render it like this from another ERB file:

<%= render_simple_cell :users, :my_action, my_variable: "Test" %>

Check if a variable has been given:

class MyCell < SimpleCells::BaseCell
  def my_method
    if simple_cell_argument?
      puts "Variable has been given"
    else
      puts "Variable has not been given"
    end
  end
end

Testing

You can test your cells individually like this:

require "rails_helper"

describe "my cell" do
  it "renders" do
    helper = SimpleCells::SpecHelper.new("users/something", :show)
    expect(helper.body).to include "some text"
  end
end

License

This project rocks and uses MIT-LICENSE.

About

An attempt at writing a very simple cells gem.

Resources

License

Releases

No releases published

Packages

No packages published
You can’t perform that action at this time.