Model Based HTML plugin

Plugin details

Rails plugin for binding html to models

Websitehttp://github.com/iain/model_based_html Repositorygit://github.com/iain/model_based_html.git Author Iain Hecker LicenseMIT

Documentation

Install the plugin:
ruby script/plugin install git://github.com/iain/model_based_html.git

This plugin enables the binding of other html elements to models, comparable with form_for. The idea is that you can bind common html-elements to an object or collection and that you can easily view the data. At the moment, it includes definition lists and tables. For any suggestions, please send me a message.

This plugin works best with Haml, which I strongly recommend. This plugin works fine with ERB though.

This plugin requires Rails 2.2 or higher!

Definition Lists
=======================

I’ll start with an example, which explains the basic methods you can use:

- definition_list_for @user do |dl| 
- dl.dt_and_dd :login do |login| = link_to(login, @user) 
- dl.dt_and_dd_h :name 
- dl.dt :email 
- dl.dd :email do |mail_address| = mail_to mail_address 
- dl.dtsome other value’ 
- dl.dd_h :signature



The dt method will automatically display the human_attribute_name of this attribute (and thus translate it), the dd will automatically show the value of this attribute. You can pass a block to these methods to play with the value even more, like making it a link. Because these values may be harmful, a dd_h method is also available, sanitizing html automatically. You can limit it to one line, using dt_and_dd or dt_and_dd_h.

Further Documentation

There is currently no advanced documentation for this plugin.

New documentation

Edit plugin | (0 older versions) | Last edited by: hardway, 9 months ago