# Formie [![Gem Version](https://badge.fury.io/rb/formie.svg)](https://badge.fury.io/rb/formie) Tired of programming each HTML tag? Are you in search of DRYness for Rails views? May be Formie can help you. Formie implements low level template-based helpers. It injects the formies into the ActionView module. The form-bounded as well as the unbounded templates are supported. Still, the ActionView functionality (e.g. text_field) is kept untouched. In short, Formie is like a helper using the notation of a partial. Templates handlers are supported as in partials. ## Installation As usual: ```ruby # Gemfile gem "formie" ``` and run "bundle install". ## Description Templates for Formie are hosted in: - /forms (bounded to form) - /application (free standing) - /templates (free standing) Till Rails 5 is 'app/formies'. Starting at Rails 6 is 'app/views/formies'. Version 1.1.0+ is intended for Rails 7 Inside a formie the following locals (as delivered by the controller) are available: |Name | Description | --- | --- | action_name | args | remainings after extracting options/locals | block | block passed to the formie | controller_name | form | (available inside form_with (similar to fields_for)) | form.object | params Locals are passed in a hash. The controller attributes are available as usual. To avoid a server restart during development of formies you may add to: ```ruby # app/controllers/application_controller.rb before_filter do Formie.reload if Rails.env.development? end ``` ## Examples (see also tests) ```ruby <%= copyright %> <%= back %> <%= show obj: @order %> <%= form_with model: Order do |f| %> <%= f.l_text_field :who %> <%= f.l_text_field :amount %> <% end %> ``` In directory : ```ruby # application/copyright.html.erb # application/back.html.erb "> Back # application/show.html.erb "> Show # forms/l_text_field.html.erb <% field = args.first %>

<%= form.label field %>
<%= form.text_field field %>

# templates/hello.slim / a comment span Hello Slim ``` ## Miscellaneous Copyright (c) 2009-2023 Dittmar Krall (www.matiq.com), released under the MIT license: * https://opensource.org/licenses/MIT