Project

marilyne

0.0
No commit activity in last 3 years
No release in over 3 years
Use presenter pattern in rails easily.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Runtime

~> 4.0.3
 Project Readme

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