Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Stubbed out template files for initializer and form field partial

  • Loading branch information...
commit ce46cde4325fe51cd3b91a709befb141a3491ff5 1 parent 0cf599a
@nfm nfm authored
View
11 lib/generators/better_form/better_form_generator.rb
@@ -0,0 +1,11 @@
+require 'rails/generators'
+
+class BetterFormGenerator < Rails::Generators::Base
+ source_root File.join(File.dirname(__FILE__), "templates")
+
+ desc 'Install the default better_form initializer and partial'
+ def generate
+ template "better_form.rb", "config/initializers/better_form.rb"
+ template "field.html.erb", "app/views/better_form/_field.html.erb"
+ end
+end
View
8 lib/generators/better_form/templates/better_form.rb
@@ -0,0 +1,8 @@
+module BetterForm
+ class Builder
+ def better_form_field(field)
+ content = @template.render(:partial => 'better_form/field', :locals => { :field => field })
+ content
+ end
+ end
+end
View
10 lib/generators/better_form/templates/field.html.erb
@@ -0,0 +1,10 @@
+<div>
+ <%= field[:label] %>
+ <span class="prefix">
+ <%= field[:prefix] %>
+ <%= field[:field] %>
+ <%= field[:suffix] %>
+ <%= field[:description] %>
+ </span>
+ <%= field[:error_message] %>
+</div>
Please sign in to comment.
Something went wrong with that request. Please try again.