ViewModels
A view model/representer solution for Padrino and Rails.
Features
- Polymorph view model objects that correspond to model objects.
- View model specific templates.
- Hierarchical Template Rendering: Allows generalized templates for a class tree of view models.
- Helper methods directly on the view models.
- No view related code in the models.
- A clean API for use in Padrino/Rails.
- 100% rcov coverage, nice metrics, gallons of blood and sweat by excellent contributors.
Installation
Padrino (via Gem)
Note: The Padrino API might change as I get acquainted with the Padrino way of doing things. Basic calls like render_as without all its options will stay the same, and so will view_model_for.
gem install view_models
and then adding the line
gem 'view_models', '>=2.0.0' # for example
in your Gemfile, followed by your app file(s):
require 'view_models'
...
class MyApplication < Padrino::Application
register Padrino::ViewModels
...
end
Note: Adheres to the Padrino style by explicitly registering.
Rails (via Gem)
gem install view_models
and then adding the line
config.gem 'view_models'
in your environment.rb.
Links Galore!
Usage, Examples, In-depth Infos [Wiki] Reference [RDoc] Gem [RubyGems.org] Mailing List Bug Tracker Metrics Source [Github] Homepage