Skip to content

alaibe/marilyne

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Marilyne Build Status Dependency Status Code Climate

Marilyne is a Gem which allows you to use presenter patten easily into your rails project

Resources

Bugs

Development

Testing

Source

  • git://github.com/alaibe/marilyne.git

Install

Add this to your Gemfile

  gem 'marilyne'

Usage

You must generate your presenter

  rails g marilyne:presenter base # => app/presenters/base_presenter.rb

And in your view you can call

  <%= presenter_for('template', object: @base) %>

Exemple

Basic usage:

  presenter_for('base')
    # => render partial: 'base', object: BasePresenter.new(template, Base.new)

It's possible to specify the object you want present:

  presenter_for('base', object: @object)
    # => render partial: 'base', object: BasePresenter.new(template, @object)

or multiple object

  presenter_for('base', objects: [@object, @other_object])
    # => render partial: 'base', object: BasePresenter.new(template, @object, @other_object)

A block can also be passed and the the render will be call only if block is true

  presenter_for('base', object: @object) { |object| object.ok? }

Finally, it's also possible to pass a presenter in options

  presenter_for('base', presenter: 'MySpecificPresenter', object: @object)
    # => render partial: 'base', object: MySpecificPresenter.new(template, @object)

Contributors

*Anthony Laibe

Bitdeli Badge

About

Use presenter pattern in rails easily

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published