Middleman Decorators
Use Decorators (AKA Presenters) in Middleman.
This project is not yet stable so use with caution.
Installation
Add this line to your application's Gemfile:
gem 'middleman-decorators', '~> 1.0'
And then execute:
$ bundle install
Usage
Activate the extension in config.rb
:
activate :decorators
By default, decorators are added to $app_root/decorators
Example decorator:
class WidgetDecorator < Middleman::Decorators::Base
def complex_method
[..]
end
end
To use the decorator in a view:
<% decorate(data.widgets, WidgetDecorator).complex_method %>
Contributing
If there is any thing you'd like to contribute or fix, please:
- Fork the repo
- Make your changes
- Add specs for any new functionality
- Verify all existing tests work properly
- Make a pull request